杭电 5363 求集合的非空子集中key的数量

Description

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.
 

Input

There are multiple test cases. The first line of input contains an integer  , indicating the number of test cases. For each test case: 

The first line contains an integer  , the number of integers in the set.
 

Output

For each test case, output the number of key sets modulo 1000000007.
 

Sample Input

4
1
2
3
4
 

Sample Output

0
1
3
7
 
 
 1 #include<cstdio>
 2 __int64 f(__int64 a)
 3 {
 4     __int64 b=2;
 5     __int64 t=1;
 6     while(a)
 7     {
 8         if(a % 2 != 0)
 9         {
10             t=(t*b)%1000000007;
11         }
12         b=b*b%1000000007;
13         a/=2;
14     }
15     return t;
16 }
17 int main()
18 {
19     int t;
20     scanf("%d",&t);
21     while(t--)
22     {
23         __int64 n;
24         scanf("%I64d",&n);
25         printf("%I64d\n",f(n-1)-1);
26     }
27     
28 }

 

posted @ 2016-07-23 11:43  野小子&  阅读(114)  评论(0编辑  收藏  举报