HDU 5363 Key Set (Fast power modulo)

Source: Internet
Author: User

Key Set



Problem Descriptionsoda have a set $S $ with $n $ integers $\{1, 2, \dots, 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 $ is key set.

Inputthere is multiple test cases. The first line of input contains an integer $T $ $ (1 \le T \le 10^5) $, indicating the number of test cases. For each test case:

The first line contains a integer $n $ $ (1 \le n \le 10^9) $, the number of integers in the set.

Outputfor each test case, output the number of key sets modulo 1000000007.

Sample Input4 1 23 4

Sample Output0 1 3 7
1#include <cstdio>2 using namespacestd;3 4 Const Long Long intMod=1000000007;5 6 voidQuickmod (intAintBLong LongN)7 {8     Long Longres=1, temp=a%N;9      while(b)Ten     { One         if(b&1) res= (res*temp)%N; Atemp= (temp*temp)%N; -b>>=1; -     } theprintf"%lld\n", res-1); - } -  - intMain () + { -     intT,n; +scanf"%d",&t); A      while(t--) at     { -scanf"%d",&n); -Quickmod (2, N-1, MoD); -     } -     return 0; -}

HDU 5363 Key Set (Fast power modulo)

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.