#P16167. [ICPC 2015 NAIPC] Extensive Or

[ICPC 2015 NAIPC] Extensive Or

题目描述

Consider a very large number RR in a compressed format. It is compressed as a binary string ss, and an integer kk. Start with the empty string, and append ss to it kk times to get the binary representation of RR. The string ss is guaranteed to have a leading 11. Now, with RR, solve the following problem: How many sets of nn distinct integers are there such that each integer is between 00 and R1R - 1, inclusive, and the XOR of all those integers is equal to zero? Since this number can get very large, return it modulo 109+710^9 + 7.

As a reminder, XOR is Exclusive Or. The XOR of two numbers is done bitwise. Using \oplus for XOR:

$$\begin{aligned} 0 \oplus 0 &= 0 \\ 0 \oplus 1 &= 1 \\ 1 \oplus 0 &= 1 \\ 1 \oplus 1 &= 0 \\ \end{aligned}$$

XOR is associative, so a(bc)=(ab)ca \oplus (b \oplus c) = (a \oplus b) \oplus c.

输入格式

Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. Each input consists of exactly two lines. The first line has two space-separated integers nn (3n73 \leq n \leq 7) and kk (1k1000001 \leq k \leq 100000), where nn is the number of distinct integers in the sets, and kk is the number of times to repeat the string ss in order to build RR. The second line contains only the string ss, which will consist of at least 11 and at most 5050 characters, each of which is either 00 or 11. ss is guaranteed to begin with a 11.

输出格式

Output a single line with a single integer, indicating the number of sets of nn distinct integers that can be formed, where each integer is between 00 and R1R - 1 inclusive, and the XOR of the nn integers in each set is 00. Output this number modulo 109+710^9 + 7.

3 1
100
1
4 3
10
1978
5 100
1
598192244