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

HDU5363:Key Set

时间:2015-08-07 13:27:28      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:hdu

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


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

HDU5363:Key Set

标签:hdu

原文地址:http://blog.csdn.net/libin56842/article/details/47336771

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