标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4384 Accepted Submission(s):
1374
#include<stdio.h> #include<string.h> #include<algorithm> #define LL long long #define mod 200907 using namespace std; LL fun(LL a,LL b) { LL ans=1; //a=a%mod; while(b) { if(b&1) ans=(a*ans)%mod; b/=2; a=(a*a)%mod; } return ans; } int main() { int t; LL x,y,x1,y1; LL a,b,c,k; LL ans; scanf("%d",&t); while(t--) { scanf("%lld%lld%lld%lld",&a,&b,&c,&k); if(2*b==a+c)//等差数列 printf("%lld\n",(a+(c-b)*(k-1))%mod); else //等比数列 printf("%lld\n",(((fun((c/b),k-1))%mod)*(a%mod))%mod); } return 0; }
hdoj 2817 A sequence of numbers【快速幂】
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4963383.html