# HDU5363:Key Set

Problem 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  T   (1T105) , indicating the number of test cases. For each test case:

The first line contains an integer  n   (1n109) , 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


Source

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

#define ls 2*i
#define rs 2*i+1
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define LL long long
#define N 1005
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define rank rank1
const int mod = 1000000007;
LL ppow(LL a,LL b)
{
LL c=1;
while(b)
{
if(b&1) c=c*a%mod;
b>>=1;
a=a*a%mod;
}
return c;
}
int main()
{
int t;
LL n;
scanf("%d",&t);
while(t--)
{
scanf("%I64d",&n);
printf("%I64d\n",ppow(2,n-1)-1);
}

return 0;
}

• 点赞
• 评论 1
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

键盘上的舞者

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文
08-06 794
08-08 336

08-06 289
08-06 1517
08-12 384
08-06 327
05-31 252
08-07 27
08-07 1233