hdu 5363 Key Set(水)
2015-08-07 19:23
274 查看
题目链接:hdu 5363 Key Set
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int pow_mod (long long x, int n) {
long long ans = 1;
while (n) {
if(n&1)
ans = ans * x % mod;
x = x * x % mod;
n >>= 1;
}
return ans;
}
int main () {
int cas, n;
scanf("%d", &cas);
while (cas--) {
scanf("%d", &n);
printf("%d\n", (pow_mod(2, n-1) + mod - 1) % mod);
}
return 0;
}
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod = 1000000007;
int pow_mod (long long x, int n) {
long long ans = 1;
while (n) {
if(n&1)
ans = ans * x % mod;
x = x * x % mod;
n >>= 1;
}
return ans;
}
int main () {
int cas, n;
scanf("%d", &cas);
while (cas--) {
scanf("%d", &n);
printf("%d\n", (pow_mod(2, n-1) + mod - 1) % mod);
}
return 0;
}
相关文章推荐
- javascriptcore.framework学习.
- hdu 5361 In Touch(最短路+并查集)
- 杭电acm 2139 Calculate the formula
- Java IO流--IO包中的其他类
- 【bzoj2141】 排队 树状数组+主席树
- Python简单爬虫
- HDU 5355 Cake(数学 DFS)
- POJ-2136 Vertical Histogram-用*号统计字母个数
- C++(12)STL实践与分析之顺序容器
- Python正则表达式速查表
- hdu 2084 - 数塔(解题报告)
- codeforces Gym 100418D BOPC 打表找规律,求逆元
- java容器类---ArrayList
- 简介BFC
- POJ-1833 排列-字典序
- List,Map的遍历
- 考试排名(一)(结构体专题)
- ANDROID内存优化——大汇总(转)
- 【CODEFORCES】 A. Expression
- poj 1185 炮兵阵地 (状态压缩)