#K91012. Counting Unique Strings with Wildcards
Counting Unique Strings with Wildcards
Counting Unique Strings with Wildcards
You are given a string s
consisting of lowercase letters and the wildcard character *
. Each *
can be replaced by either an empty string or any lowercase letter (a total of 27 possibilities). Your task is to compute the total number of unique strings that can be generated by applying these replacements.
For example, if s
contains no wildcards, there is exactly 1 unique string. If there is 1 wildcard, there are 27 possible strings, and if there are 2 wildcards, there will be 272 unique strings.
Note: The answer is computed as \(27^{(\text{number of } * \text{ in } s)}\).
inputFormat
The input consists of a single line containing the string s
. The string may be empty and will only consist of lowercase alphabetical characters and the character *
.
outputFormat
Output a single integer representing the total number of unique strings that can be formed by replacing each *
with either an empty string or any lowercase letter.
brze
1