码迷,mamicode.com
首页 > 其他好文 > 详细

求集合的非空子集中key的数量

时间:2016-07-23 13:21:06      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

Description

soda has a set 技术分享 with 技术分享 integers 技术分享技术分享技术分享技术分享技术分享技术分享技术分享技术分享技术分享. 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 技术分享 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 }

 

求集合的非空子集中key的数量

标签:

原文地址:http://www.cnblogs.com/yexiaozi/p/5698313.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!