Source of BUPT3D 田田的账号

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
ll qpow(ll bottom, int exp, int MOD) {
ll ans = 1;
while (exp > 0) {
if ((exp & 1) == 1)
ans = (ans * bottom) % MOD;
bottom = (bottom * bottom) % MOD;
exp >>= 1;
}
return ans;
}
int main() {
int T, n;
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
printf("%lld\n", qpow(4, n-1, 1000000007));
}
return 0;
}

返回