QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#603787 | #9376. Game | ffforest-lzn | WA | 0ms | 3540kb | C++14 | 655b | 2024-10-01 19:09:43 | 2024-10-01 19:09:48 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
int x,y,a0,a1,b,p0,p1,ans;
int qpow(int a,int b){
int res=1;
while(b){
if(b&1) res=1ll*res*a%mod;
a=1ll*a*a%mod;
b>>=1;
}
return res;
}
int inv(int x){
return qpow(x,mod-2);
}
void work(){
cin>>x>>y;
cin>>a0>>a1>>b;
b=inv(a0+a1);
p0=1ll*a0*b%mod;
p1=1ll*a1*b%mod;
if(x<y) ans=qpow(p0,ceil((y-x)/x)+1);
else if(x==y) ans=p0;
else{
ans=1ll*(1ll-qpow(p1,(x-y)/y+1)+mod)%mod*inv((1ll-p1+mod)%mod)%mod;
ans=1ll*ans*p0%mod;
}
cout<<ans<<"\n";
}
int main(){
int T;
cin>>T;
while(T--) work();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3540kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
499122177 910398850 99824436
result:
wrong answer 3rd lines differ - expected: '220911476', found: '99824436'