首页 > 代码库 > HDU 2817: A sequence of numbers
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。