#C3037. Counting Possible Strings
Counting Possible Strings
Counting Possible Strings
You are given a number of test cases T and for each test case a string. The string consists of lowercase English letters, underscore characters (_
), and question marks (?
). For every occurrence of ?
in the string, it can be replaced by any one of the 26 lowercase English letters. Other characters remain unchanged.
Your task is to calculate the total number of unique strings that can be generated by replacing each ?
with any letter. Mathematically, if a string contains k instances of ?
, then the total number of distinct strings is given by:
For example, if the string is "a?c", then there is only 1 question mark, and the number of possible strings is \(26^1 = 26\). If the string is "??" then the answer is \(26^2 = 676\).
inputFormat
The first line of input contains an integer T
representing the number of test cases. Each of the following T
lines contains a single string s
composed of lowercase letters, underscores (_
), and question marks (?
).
outputFormat
For each test case, output a single line with the number of possible unique strings that can be formed by replacing each ?
with any lowercase English letter.
1
a_d
1
</p>