#P6045. 后缀树
后缀树
Description
For a string , we define as the length of .
Next, we define as the -th character of , and as the string formed by concatenating, from left to right, the -th character to the -th character of .
Given , find how many different strings satisfy all of the following:
- .
- contains only lowercase letters.
- There does not exist an integer such that is a substring of .
For the third constraint, in simpler words: there is no way to split the string into two parts such that the first part is a substring of the second part.
Two strings and are different if and only if or . If you do not know what this means, you can just think that they look different.
Poor Eztsu cannot solve it, so you need to help her.
The answer may be very large. You only need to output the value of the answer modulo .
Additional note:
is a substring of if and only if there exist such that .
Input Format
One line containing a positive integer , as described in the statement.
Output Format
One line containing an integer: the answer modulo .
2
650
105383595
114514
Hint
Sample Explanation
For the first sample, it is not hard to see that the string satisfies the requirements if and only if the two characters are different. Therefore, the answer is , which can be understood as the number of ways to choose any two characters minus the number of ways where the two characters are the same.
Constraints
This problem uses bundled testdata.
For all test points, is guaranteed.
.
.
No special constraints.
Hint
There are lowercase letters in total.
Translated by ChatGPT 5
京公网安备 11011102002149号