#include<stdio.h>
#define N 1000000007
__int64 quickpow(int a,int b) {
__int64 ans=1,base=a;
while(b) {
if(b&1) {
ans=ans*base%N;
}
base=base*base%N;
b>>=1;
}
return ans;
}
int main() {
int T;
scanf("%d",&T);
while(T--) {
int n;
scanf("%d",&n);
__int64 t;
t=quickpow(2,n-1)-1;
printf("%I64d\n",t);
}
return 0;
}
[http://acm.hdu.edu.cn/showproblem.php?pid=5363](http://acm.hdu.edu.cn/showproblem.php?pid=5363)

本文介绍了一种利用快速幂运算解决大数幂次方计算的方法,并通过一个具体的编程实例展示了如何在程序中实现该算法。该算法适用于需要高效进行指数运算的场景,尤其是在竞赛编程中面对大数运算的问题。
1万+

被折叠的 条评论
为什么被折叠?



