您的位置:首页 > 编程语言

2013腾讯编程马拉松初赛第一场(3月21日)小明系列故事——师兄帮帮忙

2013-03-23 09:47 429 查看
#include<iostream>
using namespace std;

#define LL long long
const int mod = 1000000007;

LL data[10005];
LL binary_power(int t,LL k){
if(t == 0) return 1;
if(t == 1) return k;
LL r = binary_power(t>>1,k);
if(t & 1) r = ((r * r) % mod * k) % mod;
else r = (r * r) % mod;
return r;
}
int main(){
int T,n,t,k;
cin>>T;
while(T--){
cin>>n>>t>>k;
for(int i = 0;i != n;++i)
cin>>data[i];
LL p = binary_power(t,k);
for(int i = 0;i != n;++i){
cout<<data[((i-t)%n+n)%n]*p%mod;
if(i != n-1) cout<<" ";
else cout<<endl;
}
}
return 0;
}


题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4506

二分幂~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐