HDU 5363 Key Set

Source: Internet
Author: User

Http://acm.hdu.edu.cn/showproblem.php?pid=5363Key Set

Time limit:2000/1000 MS (java/others) Memory limit:131072/131072 K (java/others)
Total submission (s): 549 Accepted Submission (s): 338


Problem 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 Output0137

int Pow (int a, int b)
{
int ans = 1;
while (b)
{
if (b% 2 = = 1)
Ans *= A;
A *= A;
b/= 2;
}
return ans;
}//the power of fast number to the power of B

#include <iostream>#include<cstdio>#include<cstring>#include<cmath>using namespacestd;#defineN 500Long LongPow (Long LongALong LongBLong Longc) {    Long LongAns =1; A%=C;  while(b) {if(b%2==1) ans= (ans * a)%C; A= (A * a)%C; b/=2; }    returnans;}//The power of the fast number, the B power of A, C is to take the remainder of CintMain () {intT; Long LongN, Num; scanf ("%d", &t);  while(t--) {scanf ("%lld", &N); Num= Pow (2N1,1000000007); printf ("%lld\n", Num-1); }    return 0;}

HDU 5363 Key Set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.