soda has a set
S with
n integers
{1,2,…,n}. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of
S are key set.
InputThere are multiple test cases. The first line of input contains an integer
T
(1≤T≤105), indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤109), the number of integers in the set. OutputFor each test case, output the number of key sets modulo 1000000007. Sample Input
4 1 2 3 4Sample Output
0 1 3 7
#include<stdio.h>
const long long n=1e9+7;
long long pow(long long a){
long long s=2,temp=1;
while(a){
if(a&1) temp=temp*s%n;
s=s*s%n;
a>>=1;
}
return temp;
}
int main(){
int T;
long long a;
scanf("%d",&T);
while(T--){
scanf("%lld",&a);
a-=1;
printf("%lld\n",pow(a)-1);
}
return 0;
} //注意找到规律2^n-1,然后就是位运算的用法。