码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 5363 Key Set(快速幂取模)

时间:2015-08-07 19:17:46      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

Key Set



 

Problem Description
soda has a set $S$ with $n$ integers $\{1, 2, \dots, n\}$. A set is called key set if the sum of integers in the set is an even number. He wants to know how many nonempty subsets of $S$ are key set.
 

 

Input
There are 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 an integer $n$ $(1 \le n \le 10^9)$, the number of integers in the set.
 

 

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

 

Sample Input
4
1
2
3
4
 

 

Sample Output
0
1
3
7
 
 1 #include<cstdio>
 2 using namespace std;
 3 
 4 const long long int mod=1000000007;
 5 
 6 void quickmod(int a,int b,long long n)
 7 {
 8     long long res=1,temp=a%n;
 9     while(b)
10     {
11         if(b&1)res=(res*temp)%n;
12         temp=(temp*temp)%n;
13         b>>=1;
14     }
15     printf("%lld\n",res-1);
16 }
17 
18 int main()
19 {
20     int t,n;
21     scanf("%d",&t);
22     while(t--)
23     {
24         scanf("%d",&n);
25         quickmod(2,n-1,mod);
26     }
27     return 0;
28 }

 

HDU 5363 Key Set(快速幂取模)

标签:

原文地址:http://www.cnblogs.com/homura/p/4711429.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!