QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#590713 | #9376. Game | Lanzy | TL | 0ms | 3652kb | C++14 | 891b | 2024-09-26 10:26:10 | 2024-09-26 10:26:11 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int N=2e5+10,mod=998244353;
int Qpow(int x,int y){
int res=1;
while(y){
if(y&1) res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res;
}
int inv(int x){
return Qpow(x,mod-2);
}
int x,y,a0,a1,b,ans,s0,s1;
void dfs(int x,int y,int p){
if(x<=0||y<=0) return;
if(x>=y){
ans+=p*s0%mod;
ans%=mod;
dfs(x-y,y,p*s1%mod);
}else{
dfs(x,y-x,p*s0%mod);
}
}
void sol(int cases){
cin>>x>>y;
cin>>a0>>a1>>b;
ans=0;
s0=a0*inv(a0+a1)%mod;
s1=a1*inv(a0+a1)%mod;
dfs(x,y,1);
cout<<ans<<'\n';
}
signed main(){
IOS;
int t=1;
cin>>t;
for(int i=1;i<=t;++i){
sol(i);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3652kb
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...