HDU 5363Key Set

Source: Internet
Author: User

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

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.