luogu#P16339. 「WAOI Round 4.5」无尽循环
「WAOI Round 4.5」无尽循环
Problem Description
Define as the string obtained by repeating the string exactly times. For example:
$$\operatorname{repeat}(\texttt{AAAB}, 3) = \texttt{AAABAAABAAAB}$$Define the numeric value of a lowercase string as follows:
Replace each character in with the difference between the ASCII code of and the ASCII code of the lowercase letter a, then interpret the resulting sequence as a base- number.
For example, the numeric value of is:
Now define a repeat transformation on a lowercase string :
After applying the repeat transformation to , the string becomes
$$\operatorname{repeat}(s, \text{numeric value of } s)$$Now, wwwwwza has a lowercase string . He wants to know the value of the numeric value of after applying the repeat transformation exactly times, modulo .
Input Format
The first line contains two positive integers, and .
The second line contains a lowercase string .
Output Format
Output a single integer, representing the answer.
1 11
c
54
2 13
c
1966
Hint
Explanation of Sample 1
The numeric value of c is , so after one repeat transformation, becomes cc.
The numeric value of cc is: .
Explanation of Sample 2
From Sample 1, after one repeat transformation, becomes cc, whose numeric value is .
So after the second repeat transformation, becomes ccc...c with a total of occurrences of c.
Therefore, the numeric value of is $\sum_{i=0}^{107} 2 \times 26^i \equiv 1966 \pmod{2^{13}}$.
Constraints
Let denote the length of .
For of the data:
- ;
- ;
- ;
- consists only of lowercase English letters.
| Subtask | Score | ||
|---|---|---|---|