Extensive Or
Time limit3sMemory limit256 MB
Count n-element subsets of numbers below the huge binary bound formed by repeating s k times whose xor is zero, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Bit manipulation
- Solved
- No attempts yet
Problem
A very large number is given in compressed form. The compression is a binary string and an integer . Start from the empty string and append to it times to get the binary representation of . The first character of is always 1.
For that , answer the following. How many sets of distinct integers are there such that every element is between 0 and inclusive and the XOR of all elements is 0? The count can get very large, so report it modulo .
XOR is exclusive or, and the XOR of two numbers is taken bit by bit. Writing for XOR:
XOR is associative, so .
Input
The input is a single test case and has exactly two lines. The first line has two space separated integers and (, ), where is the number of distinct integers in a set and is how many times is repeated to build . The second line has the string . Its length is between 1 and 50, every character is 0 or 1, and the first character is 1.
Output
Print on one line the number of sets of distinct integers, each between 0 and inclusive, whose elements XOR to 0, modulo .