QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#581230 | #9376. Game | MENDAX | TL | 0ms | 3668kb | C++14 | 763b | 2024-09-22 11:00:22 | 2024-09-22 11:00:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
const int N=2e5+5,mod=998244353;
int qmi(int a,int k){
a%=mod;
int res=1;
while(k){
if(k&1) res=res*a%mod;
a=a*a%mod;
k>>=1;
}
return res;
}
int ans=0;
int p0,p1;
void dfs(int x,int y,int p){//p0
if(x==y){
ans+=p0*p%mod;
return ;
}
if(x>y){
ans+=p*p0%mod;
ans%=mod;
dfs(x-y,y,p*p1%mod);
}
else {
dfs(x,y-x,p*p0%mod);
}
}
void slove(){
int x,y;cin>>x>>y;
ans=0;
int a0,a1,b;cin>>a0>>a1>>b;
p0=a0*qmi(a0+a1,mod-2),p1=a1*qmi(a0+a1,mod-2);
dfs(x,y,1);
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int T=1;
cin>>T;
while(T--) slove();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3668kb
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
Time 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...