2015 multiply 6 1011

来源:互联网 发布:catiav5r22软件下载 编辑:程序博客网 时间:2024/06/04 19:41


Key Set

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 207    Accepted Submission(s): 135


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
41234
 

Sample Output
0137
 

Source
2015 Multi-University Training Contest 6
 

Recommend
wange2014   |   We have carefully selected several similar problems for you:  5363 5362 5361 5360 5359 

//#pragma comment(linker, "/STACK:1024000000,1024000000")#include<cstdio>#include<cmath>#include<stdlib.h>#include<map>#include<set>#include<time.h>#include<vector>#include<queue>#include<string>#include<string.h>#include<iostream>#include<algorithm>using namespace std;#define eps 1e-8#define INF 0x3f3f3f3f#define LL long long#define max(a,b) ((a)>(b)?(a):(b))#define min(a,b) ((a)<(b)?(a):(b))typedef pair<int , int> P;#define mod 1000000007int main(){    int T;    scanf("%d", &T);    while(T--)    {        int n;        scanf("%d", &n);        int ans = 1;        int a = 2;        n--;        while(n)        {            if(n & 1) ans = ((LL)ans * a) % mod;            a = ((LL)a * a) % mod;            n >>= 1;        }        ans--;        printf("%d\n", ans % mod);    }    return 0;}


1 0
原创粉丝点击