#P15757. [JAG 2025 Summer Camp #1] Inversion of Suffix Array
[JAG 2025 Summer Camp #1] Inversion of Suffix Array
Description
You are given positive integers , and a string of length consisting of lowercase English letters.
Let be the string obtained by concatenating copies of .
Find the inversion number of the Suffix Array of , modulo .
For a string of length , the suffix array of is a permutation of integers from to that represents the starting positions of all non-empty suffixes of , sorted in lexicographical order.
Input Format
The input is given in the following format:
- is a string of length consisting of lowercase English letters.
- and are integers.
Output Format
Output the answer in a single line.
4 2
icpc
18
13 92025
jagsummercamp
996562345
京公网安备 11011102002149号