K-pop Strings
Time limit7sMemory limit512 MB
Count strings of length n over 35 characters that contain no tandem repeat of length n-k or more, modulo 998244353.
- Level
Hard8 of 10
- Topics
- String, Dynamic programming, String matching
- Solved
- No attempts yet
Problem
A substring is a tandem repeat if is even and .
Gennady built a method for counting the tandem repeats in a string with suffix structures. Now he has come up with a new type of string based on tandem repeats. Gennady calls a string of length a K-pop string if it has no tandem repeat of length or more. Count the K-pop strings of length that use only the characters "1", "2", ..., "9", "a", "b", ..., "z", modulo 998244353.
Input
The first line contains two integers and , where is the required length of the string and is the parameter (, ).
Output
Output one integer: the number of K-pop strings of length for the given that use only nonzero digits and lowercase letters, modulo 998244353.
Hint
The answer for the first input is 35 because every string of length 1 is valid: "1", "2", ..., "9", "a", "b", ..., "z". The answer for the second input is .