思路:
简单地快速幂一下就完了。
#include<cstdio> #include<iostream> using namespace std; const long long mod = 200907; long long quickpow(long long a, long long b, long long p){ long long res = 1; while(b){ if(b & 1) res = res * a % p; a = a * a % p; b >>= 1; } return res; } long long T; int main(void){ cin >> T; while(T--){ long long a, b, c, k; cin >> a >> b >> c >> k; if(c - b == b - a){ printf("%lld\n", (a + ((k - 1) % mod) * ((c - b) % mod)) % mod); } else{ printf("%lld\n", ((a % mod) * (quickpow((c / b) % mod, k - 1, mod)) % mod)); } } }
原文地址:https://www.cnblogs.com/junk-yao-blog/p/9505480.html
时间: 2024-11-07 14:08:46