题目链接:​​http://acm.hdu.edu.cn/showproblem.php?pid=2817​​​
题意:给你一个数列的前三项,让你求第k项,这个数列可能是等差也可能是等比
解析:直接判断等差还是等比,等比用快速幂,等差就直接套公式a0+(n-1)*d

#include <bits/stdc++.h>
using namespace std;
const int mod = 200907;
long long qpow(long long x,int n)
{
long long res = 1;
while(n)
{
if(n&1)
res = res*x%mod;
x = x*x%mod;
n>>=1;
}
return res;
}
int main(void)
{
int n;
scanf("%d",&n);
while(n--)
{
long long t1,t2,t3,k;
scanf("%I64d %I64d %I64d %I64d",&t1,&t2,&t3,&k);
long long ans;
if(t2-t1==t3-t2)
{
long long d = t2-t1;
ans = (t1+(k-1)*d%mod)%mod;
}
else
{
long long q = t3/t2;
ans = t1*qpow(q,k-1)%mod;
}
printf("%I64d\n",ans);
}
return 0;
}