标签:include text 接受 题目 快速幂 注意 scan printf plm
1 #include<cstdio> 2 3 #define LL long long 4 #define mod 1000000007 5 int n, t, k; 6 LL a[10005], b[10005]; 7 8 LL quick(LL a, LL b) 9 { 10 LL ans = 1, base = a % mod; 11 while(b) 12 { 13 if(b & 1) 14 ans = (ans*base) % mod; 15 base = (base * base) % mod; 16 b>>=1; 17 } 18 return ans; 19 } 20 21 int main() 22 { 23 int T;scanf("%d", &T); 24 while(T--) 25 { 26 scanf("%d %d %d", &n, &t, &k); 27 for(int i = 1; i <= n; i++) 28 scanf("%lld", &a[i]); 29 LL cnt = quick(k, t); 30 t %= n; 31 for(int i = 1; i <= n; i++) 32 { 33 if(i-t >= 1) 34 b[i] = (a[i-t] * cnt) % mod; 35 else 36 b[i] = (a[n+i-t] * cnt) % mod; 37 } 38 for(int i = 1; i < n; i++) 39 printf("%lld ", b[i]); 40 printf("%lld\n", b[n]); 41 } 42 return 0; 43 }
hduoj 4506 小明系列故事――师兄帮帮忙【分析题意】
标签:include text 接受 题目 快速幂 注意 scan printf plm
原文地址:http://www.cnblogs.com/123tang/p/6010268.html