题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5363
#include <iostream> #include <cstdlib> #include <cstdio> #include <algorithm> #include <vector> #include <queue> #include <cmath> #include <stack> #include <cstring> using namespace std; #define Mod 1000000007 long long Pow(int x, int n) { if( n==1 ) return x; long long d = Pow(x, n/2)%Mod; if(n%2==0) return (d * d)%Mod; else return (x * d * d)%Mod; } int main() { int n, a; scanf("%d", &n); while(n--) { scanf("%d", &a); if(a==1) { printf("0\n"); continue; } long long ans = Pow(2, a-1); printf("%lld\n", ans-1); } return 0; }
时间: 2024-10-05 22:04:12