QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603787#9376. Gameffforest-lznWA 0ms3540kbC++14655b2024-10-01 19:09:432024-10-01 19:09:48

Judging History

你现在查看的是最新测评结果

  • [2024-10-01 19:09:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3540kb
  • [2024-10-01 19:09:43]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'