luogu#P16339. 「WAOI Round 4.5」无尽循环

「WAOI Round 4.5」无尽循环

Problem Description

Define repeat(s,x)\operatorname{repeat}(s, x) as the string obtained by repeating the string ss exactly xx times. For example:

$$\operatorname{repeat}(\texttt{AAAB}, 3) = \texttt{AAABAAABAAAB}$$

Define the numeric value of a lowercase string ss as follows:

Replace each character cc in ss with the difference between the ASCII code of cc and the ASCII code of the lowercase letter a, then interpret the resulting sequence as a base-2626 number.

For example, the numeric value of bc\texttt{bc} is:

1×26+2=281 \times 26 + 2 = 28

Now define a repeat transformation on a lowercase string ss:

After applying the repeat transformation to ss, the string becomes

$$\operatorname{repeat}(s, \text{numeric value of } s)$$

Now, wwwwwza has a lowercase string ss. He wants to know the value of the numeric value of ss after applying the repeat transformation exactly kk times, modulo 2p2^p.

Input Format

The first line contains two positive integers, kk and pp.

The second line contains a lowercase string ss.

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 22, so after one repeat transformation, ss becomes cc.

The numeric value of cc is: 2×26+2=542 \times 26 + 2 = 54.

Explanation of Sample 2

From Sample 1, after one repeat transformation, ss becomes cc, whose numeric value is 5454.

So after the second repeat transformation, ss becomes ccc...c with a total of 108108 occurrences of c.

Therefore, the numeric value of ss is $\sum_{i=0}^{107} 2 \times 26^i \equiv 1966 \pmod{2^{13}}$.

Constraints

Let len\operatorname{len} denote the length of ss.

For 100%100\% of the data:

  • 1len1061 \le \operatorname{len} \le 10^6;
  • 1k10181 \le k \le 10^{18};
  • 1p201 \le p \le 20;
  • ss consists only of lowercase English letters.
Subtask Score len\operatorname{len} \le kk \le
11 3030 1010 22
22 2020 10001000
33 5050 10610^6 101810^{18}