atcoder#ABC249E. [ABC249E] RLE
[ABC249E] RLE
Score : points
Problem Statement
Consider the following procedure of, given a string consisting of lowercase English alphabets, obtaining a new string:
- Split the string off at the positions where two different characters are adjacent to each other.
- For each string that has been split off, replace with a string consisting of the character which consists of, followed by the length of .
- Concatenate the replaced strings without changing the order.
For example, aaabbcccc
is divided into aaa
,bb
,cccc
, which are replaced by a3
,b2
,c4
, respectively, which in turn are concatenated without changing the order, resulting in a3b2c4
.If the given string is aaaaaaaaaa
, the new string is a10
.
Find the number, modulo , of strings of lengths consisting of lowercase English alphabets, such that the length of is smaller than that of , where is the string obtained by the procedure above against the string .
Constraints
- and are integers.
- is a prime.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 998244353
26
Those strings of which the -st, -nd, and -rd characters are all the same satisfy the condition.
For example, aaa
becomes a3
, which satisfies the condition, while abc
becomes a1b1c1
, which does not.
2 998244353
0
Note that if a string is transformed into another string of the same length, such as aa
that becomes a2
, it does not satisfy the condition.
5 998244353
2626
Strings like aaabb
and aaaaa
satisfy the condition.
3000 924844033
607425699
Find the number of strings satisfying the condition modulo .