首页 > 代码库 > HDU5363:Key Set
HDU5363:Key Set
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 integern (1≤n≤109) , the number of integers in the set.
The first line contains an integer
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
2015 Multi-University Training Contest 6
看数字找规律吧。。。
随便试试竟然就试过了。
。
#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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。