hdu 2817
模拟。
#include "iostream"
#include "algorithm"
#include "cstring"
#define int long long
#define d(x) cerr << #x << " => " << x << endl
#define dd(x) cerr << #x << endl
#define D cerr << "Passed [" << __FUNCTION__ << "] on line " << __LINE__ << endl
#define ms(x) memset(x, 0, sizeof x)
using namespace std;
int rd() {
int f = 1, val = 0; int ch = getchar();
while(!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = getchar();
while(isdigit(ch)) val = val * 10 + ch - '0', ch = getchar();
return f * val;
}
const int mod = 200907;
int qpow(int a, int b) {
int res = 1, base = a % mod;
while(b) {
if(b & 1) res = res * base % mod;
base = base * base % mod; b >>= 1;
}
return res % mod;
}
int positive(int x) {
return (x % mod + mod) % mod;
}
void solve() {
int a = rd(), b = rd(), c = rd(), k = rd();
if(b - a == c - b) {
int d = positive(b - a);
cout << positive(a + d % mod * (k - 1) % mod) << endl;
} else {
int q = b / a % mod;
cout << a * qpow(q, k - 1) % mod << endl;
}
}
signed main() {
int T = rd();
while(T--) solve();
return 0;
}
hdu 2818
带权并查集。
此处评论已关闭