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
(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.
The first line contains an integer n (1≤n≤109) , 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;
}