打表
| 1 | ||||||
|---|---|---|---|---|---|---|
| 1 | 1 | |||||
| 1 | 2 | 1 | ||||
| 1 | 2 | 4 | 1 | |||
| 1 | 2 | 4 | 8 | 1 | ||
| 1 | 2 | 4 | 8 | 16 | 1 | |
| 1 | 2 | 4 | 8 | 16 | 32 | 1 |
显然c[i][j]=2^j(列从0序开始) 数据有点大,快速幂(递归) 自己看,
#include<bits/stdc++.h>
using namespace std;
int a,b, sets;
const int mod=1000000007;
int ksm(int x, long long y) {
if (y == 0) {
return 1;
}
if (y == 1) {
return x % mod;
}
int temp = ksm(x, y >> 1);
temp = (long long)temp * temp % mod;
if (y & 1) {
temp = (long long)temp * x % mod;
}
return temp;
}
void solve(){
for(int i=0;i<sets;i++){
cin>>a;
}
for(int i=0;i<sets;i++){
cin>>b;
cout<<ksm(2,b)<<endl;
}
}
int main() {
cin>>sets;
solve();
return 0;
}