problem
C. Moamen and XOR
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Moamen and Ezzat are playing a game. They create an array a of n non-negative integers where every element is less than 2k.
Moamen wins if a1&a2&a3&…&an≥a1⊕a2⊕a3⊕…⊕an.
Here & denotes the bitwise AND operation, and ⊕ denotes the bitwise XOR operation.
Please calculate the number of winning for Moamen arrays a.
As the result may be very large, print the value modulo 1000000007 (109+7).
Input
The first line contains a single integer t (1≤t≤5)— the number of test cases.
Each test case consists of one line containing two integers n and k (1≤n≤2⋅105, 0≤k≤2⋅105).
Output
For each test case, print a single value — the number of different arrays that Moamen wins with.
Print the result modulo 1000000007 (109+7).
Example
inputCopy
3
3 1
2 1
4 0
outputCopy
5
2
1
Note
In the first example, n=3, k=1. As a result, all the possible arrays are [0,0,0], [0,0,1], [0,1,0], [1,0,0], [1,1,0], [0,1,1], [1,0,1], and [1,1,1].
Moamen wins in only 5 of them: [0,0,0], [1,1,0], [0,1,1], [1,0,1], and [1,1,1].
solution
题意:
- 给出n和k(<2e5),可以构造任意长度为n且满足ai<2^k的序列,求这些序列中满足全部相&大于等于全部异或(即a1&a2&a3…&an >= a1^a2^a3^…^an的个数),答案%(1e9+7)
思路:
- 看到2e5的范围,猜想是个结论题,所以打表找规律。
- 奇数很容易找到,偶数需要额外推一下公式