#P5404. [CTS2019] 重复
[CTS2019] 重复
Description
Country A is a country that likes repetition. In this country, a basic sentence can be represented by a lowercase letter string of length exactly . To show their love for repetition, people in Country A always repeat the sentence they want to express infinitely many times.
Sometimes, such repetition is meaningful. People in Country A call a lowercase letter string that is lexicographically smaller than the given string and has the same length as a meaningful semantic fragment. They want to know: how many different basic sentences (i.e., lowercase letter strings of length exactly ) can, after being repeated infinitely, contain at least one meaningful semantic fragment?
Input Format
The first line of the input file is a positive integer , which denotes the length of the basic sentence. The second line is a lowercase letter string , whose meaning is described above.
Output Format
Output one line with one integer, the number of basic sentences that satisfy the condition. To avoid the answer being too large, you only need to output the result modulo .
3
abc
79
5
zxcvb
11881375
20
uuopacpertklmqwbfixc
765676850
Hint
Let the length of string be . Then the constraints of and follow the table below:

For of the testdata, it is guaranteed that .
Translated by ChatGPT 5
京公网安备 11011102002149号