Title Link: Http://acm.hdu.edu.cn/showproblem.php?pid=5363Problem Descriptionsoda has a setSWithNIntegers< Span id= "mathjax-span-8" class= "Mrow" >{ 1, 2,... , n} . A set is called key set if the sum of integers in the set are an even number. He wants to know how many nonempty subsets Of s are key set.
Inputthere is multiple test cases. The first line of input contains an integerT(1≤T≤5) , indicating the number of test cases. For each test case:
The first line contains an integer n (1≤n≤9) the number of integers in the set.
Outputfor each test case, output the number of key sets modulo 1000000007.
Sample Input41234
Sample Output0 1 3 7
A look at the data is a fast power, the first with int wrong, simply change to long long
1#include <iostream>2#include <cmath>3 using namespacestd;4 5 Long LongFLong Longa)6 {7 Long Longtemp=2;8 Long Longans=1;9 while(a)Ten { One if(a%2!=0) Aans*=temp; - -ans=ans%1000000007; thetemp=temp*temp; -temp=temp%1000000007; -A/=2; - } + returnans; - } + intMain () A { at Long Longn,m; -Cin>>N; - while(n--) - { -Cin>>m; -cout <<f (M-1)-1<<Endl; in } - return 0; to}
View Code
HDU 5363Key Set