思路:
分类讨论
c o d e code code
#include<iostream>
#include<cstdio>
using namespace std;
long long t, a, b, c, n;
long long ksm(long long x, long long k)
{
long long ans=1;
while(k)
{
if(k&1)
ans=ans*x%200907;
x=x*x%200907;
k>>=1;
}
return ans;
}
int main()
{
scanf("%lld", &t);
while(t--)
{
scanf("%lld%lld%lld%lld", &a, &b, &c, &n);
if(c-b==b-a)
printf("%lld\n", (a+(c-b)*(n-1)%200907)%200907);
else
printf("%lld\n", a*ksm(b/a, n-1)%200907);
}
return 0;
}