QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#590718 | #9376. Game | Chief_Ning | RE | 0ms | 0kb | C++14 | 1.0kb | 2024-09-26 10:29:48 | 2024-09-26 10:29:49 |
answer
#include<bits/stdc++.h>
using namespace std;
using u64 = unsigned long long;
using u32 = unsigned int;
using i64 = long long;
mt19937_64 rnd(random_device{}());
const int mod = 998244353;
const int N = 3e5 + 5;
const int M = 2e6 + 5;
int n, m, s, t;
i64 fastpow(i64 a, int n) {
i64 res = 1;
a %= mod;
while(n) {
if(n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
i64 inv(i64 a) {
return fastpow(a, mod - 2);
}
int f(int x, int y, int pa, int pb) {
return fastpow(pa, y / x) * (1 - f(y % x, x, pb, pa) + mod) % mod;
}
void RuinGuard(int tc)
{
int x, y;
cin >> x >> y;
int a, b, c;
cin >> a >> b >> c;
int pa = a * inv(a + b) % mod;
int pb = b * inv(a + b) % mod;
return cout << f(x, y, pa, pb) << '\n', void();
}
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int testcase = 1;
cin >> testcase;
for(int tc = 1; tc <= testcase; tc++) {
RuinGuard(tc);
}
return 0;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15