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

2015 multiply 6 1011

时间:2015-08-06 20:30:03      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:acm   hdu   


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
4 1 2 3 4
 

Sample Output
0 1 3 7
 

Source
 

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 1000000007

int 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;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

2015 multiply 6 1011

标签:acm   hdu   

原文地址:http://blog.csdn.net/dojintian/article/details/47322089

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