C語言源碼: [cpp] #include<stdio.h> long long f(long long a,long long b) { long long ans=1; while(b) { if(b%2==1) ans=(ans*a)%200907; b=b/2; a=(a*a)%200907; } return ans; } int main() { long long a,b,c,k,n; while(scanf("%lld",&n)!=EOF) { while(n--) { scanf("%lld %lld %lld %lld",&a,&b,&c,&k); if(b-a==c-b) printf("%lld\n",(a%200907+(k-1)%200907*(b-a)%200907)%200907); else printf("%lld\n",(a%200907*f(b/a,k-1))%200907); } } }