Namomo Subsequence
Time limit3sMemory limit1024 MB
Count the length-6 subsequences of s whose equal-character pattern matches
- Level
Medium5 of 10
- Topics
- String, Dynamic programming, Hash map
- Solved
- No attempts yet
Problem
"gshfd1jkhaRaadfglkjerVcvuy0gf" said Prof. Pang.
To understand Prof. Pang's word, we would like to calculate the number of namomo subsequences of it. The word by Prof. Pang is a string with characters, where each character is either an English letter (lowercase or uppercase) or a digit. The -th character of is denoted (). A subsequence of is defined by a list of indices such that . Let be a function on two characters such that when and otherwise. is a namomo subsequence of if and only if for any , , where is the -th character of the string "namomo" ().
Output the number of namomo subsequences of a given string modulo .
Input
The first line contains a string with characters (). contains only lowercase English letters ('a' to 'z'), uppercase English letters ('A' to 'Z'), and digits ('0' to '9').
Output
Output one integer, the answer modulo .