Key Set
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 388 Accepted Submission(s): 250
The first line contains an integer n (1≤n≤109) , the number of integers in the set.
4 1 2 3 4
0 1 3 7
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 1000000007
#define INF 0x3f3f3f3f
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
ll Pow1(ll a,ll n){
ll ans=1;
while(n){
if(n&1){
ans*=a;
ans%=mod;
}
a*=a;
a%=mod;
n>>=1;
}
return (ans+mod-1)%mod;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n,t;
cin>>t;
while(t--){
scanf("%d",&n);
printf("%I64d\n",Pow1(2,n-1));
}
return 0;
}