HDU 2817: A sequence of numbers
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HDU 2817: A sequence of numbers相关的知识,希望对你有一定的参考价值。
A sequence of numbers
///@author Sycamore, ZJNU; ///@date 8/4/2017 #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll m = 200907; ll multiply(ll a, ll b) { return ((a % m) * (b % m)) % m; } ll powermod(ll a, ll b) { ll ret = 1; a %= m; while (b) { if (b & 1) ret = ret*a%m; a = (a*a) % m; b >>= 1; } return ret; } int main() { ios::sync_with_stdio(false); ll N, a1, a2, a3, k; cin >> N; while (N--) { cin >> a1 >> a2 >> a3 >> k; if (a1 + a3 == 2 * a2) cout << (a1 + multiply(k - 1, (a2 - a1))) % m << ‘\n‘; else cout << multiply(a1, powermod(a2 / a1, k - 1)) << ‘\n‘; } return 0; }
以上是关于HDU 2817: A sequence of numbers的主要内容,如果未能解决你的问题,请参考以下文章
hdu4675 GCD of Sequence 莫比乌斯+组合数学
HDU 3415 Max Sum of Max-K-sub-sequence