QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15