爱情测试
#include<stdio.h> const long long mod=100007; long long multy(long long q, long long n) { long long cnt = n; long long base = q; long long ret = 1; while(cnt > 0) { if(cnt & 1) ret = (long long)ret*base%mod; cnt = cnt >> 1; base = (long long)base*base%mod; } return ret; } int main() { long long a1,a2,a3,n,sum,q; while(scanf("%lld %lld %lld %lld",&a1,&a2,&a3,&n)!=EOF) { if(a3-a2==a2-a1) printf("%lld\n",( a1 + ((n-1)%mod) * ((a3-a2)%mod) )%mod); else { a1%=mod; q=a3/a2%mod; printf("%lld\n",a1*multy(q,n-1)%mod); } } return 0; }