QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#586076 | #9376. Game | daniel14311531 | ML | 0ms | 3704kb | C++20 | 638b | 2024-09-24 01:02:13 | 2024-09-24 01:02:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
int p1, p2;
int inv(int x) {
if(x <= 1) return 1;
return 1ll * (mod - mod / x) * inv(mod % x) % mod;
}
int calc(int x, int y) {
if(y <= 0) return 1;
if(x <= 0) return 0;
return (1ll * p1 * calc(x, y - x) + 1ll * p2 * calc(x - y, y)) % mod;
}
int main() {
ios::sync_with_stdio(0); cin.tie(nullptr);
int T; cin >> T;
for(; T; --T) {
int x, y, s; cin >> x >> y;
cin >> p1 >> p2 >> s; s = p1 + p2;
p1 = 1ll * p1 * inv(s) % mod;
p2 = 1ll * p2 * inv(s) % mod;
cout << calc(x, y) << "\n";
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3704kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
499122177 910398850 220911476
result:
ok 3 lines
Test #2:
score: -100
Memory Limit Exceeded
input:
100000 1 1000000000 12980050 128257807 266126484 1 1000000000 400255084 123438563 768881284 1000000000 1000000000 24563487 72082135 450057094 1 1000000000 56952077 40876000 193815114 1000000000 1000000000 82048274 239365585 326520865 1000000000 1 309821265 346013425 963168258 1 1 104158269 199365020...