#P16167. [ICPC 2015 NAIPC] Extensive Or
[ICPC 2015 NAIPC] Extensive Or
题目描述
Consider a very large number in a compressed format. It is compressed as a binary string , and an integer . Start with the empty string, and append to it times to get the binary representation of . The string is guaranteed to have a leading . Now, with , solve the following problem: How many sets of distinct integers are there such that each integer is between and , inclusive, and the XOR of all those integers is equal to zero? Since this number can get very large, return it modulo .
As a reminder, XOR is Exclusive Or. The XOR of two numbers is done bitwise. Using 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 .
输入格式
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 () and (), where is the number of distinct integers in the sets, and is the number of times to repeat the string in order to build . The second line contains only the string , which will consist of at least and at most characters, each of which is either or . is guaranteed to begin with a .
输出格式
Output a single line with a single integer, indicating the number of sets of distinct integers that can be formed, where each integer is between and inclusive, and the XOR of the integers in each set is . Output this number modulo .
3 1
100
1
4 3
10
1978
5 100
1
598192244