标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 5427 Accepted Submission(s): 1461
#include <stdio.h> #include <string.h> using namespace std; typedef long long LL; const int N = 10005; const LL mod = 1000000007; LL a[N]; LL pow_mod(LL a,LL n){ LL ans = 1; while(n){ if(n&1) ans = a*ans%mod; a = a*a%mod; n>>=1; } return ans; } int main(){ int tcase; scanf("%d",&tcase); int n,t; LL k; while(tcase--){ scanf("%d%d%lld",&n,&t,&k); LL M = pow_mod(k,(LL)t); for(int i=1;i<=n;i++){ LL val; scanf("%lld",&val); a[i] = M*val%mod; } int m = t%n; for(int i=(n-m+1);i<=n;i++){ printf("%lld ",a[i]); } for(int i=1;i<n-m+1;i++){ if(i!=n-m) printf("%lld ",a[i]); else printf("%lld\n",a[i]); } } }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5598072.html