#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 mm. 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 ss and has the same length as ss a meaningful semantic fragment. They want to know: how many different basic sentences (i.e., lowercase letter strings of length exactly mm) 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 mm, which denotes the length of the basic sentence. The second line is a lowercase letter string ss, 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 998244353998244353.

3
abc
79
5
zxcvb
11881375
20
uuopacpertklmqwbfixc 
765676850

Hint

Let the length of string ss be nn. Then the constraints of nn and mm follow the table below:

img

For 100%100\% of the testdata, it is guaranteed that 1n,m20001\le n,m\le 2000.

Translated by ChatGPT 5