hdu 5363 Key Set【快速幂求余】
来源:互联网 发布:java多线程运行机制 编辑:程序博客网 时间:2024/05/21 12:41
Key Set
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1314 Accepted Submission(s): 734
Problem Description
soda has a set S with n integers {1,2,…,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 ofS are key set.
Input
There are multiple test cases. The first line of input contains an integerT (1≤T≤105) , indicating the number of test cases. For each test case:
The first line contains an integern (1≤n≤109) , the number of integers in the set.
The first line contains an integer
Output
For each test case, output the number of key sets modulo 1000000007.
Sample Input
41234
Sample Output
0137
求出2^n-1,然后再-1得出结果。也算是给以后的自己留一份模板
#include<stdio.h>#include<string.h>#include<iostream>using namespace std;#define mod 1000000007int main(){ int t; cin>>t; while(t--) { int n; cin>>n; n--; long long int tmp=2; long long int ans=1; while(n) { if(n%2==1) { ans=(ans*tmp)%mod; n-=1; } else { tmp=(tmp*tmp)%mod; n/=2; } } cout<<ans-1<<endl; }}
0 0
- hdu 5363 Key Set【快速幂求余】
- hdu 5363 Key Set 矩阵快速幂
- HDU 5363 Key Set(快速幂)
- hdu 5363 Key Set (快速幂取模)
- HDU 5363 Key Set(快速幂取余)
- Hdu 5363 Key Set【快速幂运算】
- HDU 5363 Key Set(快速幂)
- HDU 5363 Key Set (快速幂)
- HDU Problem - 5363 Key Set 【快速幂】
- 【HDU】-5363-Key Set(快速幂)
- HDU Problem 5363 Key set 【快速幂】
- HDU 5363 Key Set【快速幂取模】
- Key Set 【hdu-5363】【快速幂】
- HDU 5363 Key Set
- HDU 5363 Key Set
- hdu 5363 Key Set
- HDU 5363 Key Set
- HDU 5363 Key Set
- 字符串匹配的KMP算法
- Linux centos下安装jdk、maven、ant
- 平衡二叉树---Balanced Binary Tree
- GPS转百度,百度近似转换GPS
- iOS隐藏tableview多余的分割线以及解决cell左边短20px
- hdu 5363 Key Set【快速幂求余】
- Mac 登录界面多了一个其他账户删除
- Apple 企业开发者账号&邓白氏码申请记录
- int long long
- curl网站开发指南
- 搜索算法汇总
- leetcode70-Climbing Stairs(斐波那契数列)
- 关于build.gradle的写法
- ProgressDialog(1)