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)