QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#585399 | #9376. Game | Savior | WA | 0ms | 3644kb | C++20 | 1.1kb | 2024-09-23 20:39:24 | 2024-09-23 20:39:28 |
Judging History
answer
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
#define int long long
using ll = long long;
const int inf = 2e15+7, N = 3e5+5, mod = 998244353;
typedef pair<int, int> P;
int qpow(int a,int b,int c){
int ans=1;
while(b){
if(b&1) ans=ans*a%c;
b>>=1,a=a*a%c;
}
return ans;
}
int x,y,a,b,c;
int ans=1;
void dfs(int x, int y, int cur) {
if(x == y) {
ans = (ans + cur * a) % mod;
return ;
} else if(x < y) {
int d = (y - 1) / x;
dfs(x, y - d * x, cur * qpow(a, d,mod) % mod);
} else {
int d = (x - 1) / y;
ans = (ans + cur * (1 - qpow(b, d,mod) + mod)) % mod;
dfs(x - d * y, y, cur * qpow(b, d,mod) % mod);
}
}
void solve(){
cin>>x>>y>>a>>b>>c;
int s=qpow(a+b,mod-2,mod);
a=a*s%mod,b=b*s%mod;
ans=1;
dfs(x,y,1);
cout<<ans<<endl;
return;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int t = 1;cin>>t;
while (t--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3644kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
499122178 910398851 220911477
result:
wrong answer 1st lines differ - expected: '499122177', found: '499122178'