QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#581889#9376. GamemooninseaWA 0ms3604kbC++17719b2024-09-22 14:30:552024-09-22 14:30:55

Judging History

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

  • [2024-09-22 14:30:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-09-22 14:30:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=998244353;
#define ll long long
ll quick(ll n,ll m){
	ll sum=1;
	while(m){
		if(m&1)sum=sum*n%N;
		m>>=1;
		n=n*n%N;
	}
	return sum%N;
}
ll op=1;
ll possi(ll a,ll b,ll pa, ll pb){
	if(a==b){
		return pa*quick(pa+pb,N-2)%N;
	}
	if(a<b){
		ll g=b/a;
		if(g*a!=b)b-=g*a;
		else {
			g--;
			b=a;
		}
		return possi(a,b,pa,pb)%N*quick(pa,g)%N*quick(quick(pa+pb,g),N-2)%N;
	}else{
		return (possi(a-b,b,pa,pb)%N*quick(pa+pb,N-2)*pb%N+quick(pa+pb,N-2)*pa%N)%N;
	}
}
int main(){
	int T;
	cin>>T;
	while(T--){
		int a,b;
		cin>>a>>b;
		ll qa,qb,qc;
		cin>>qa>>qb>>qc;
		op=1;
		cout<<possi(a,b,qa,qb);
		if(T==0)cout<<"\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

3
1 1
2 2 6
1 3
2 3 6
3 4
7 3 15

output:

499122177910398850220911476

result:

wrong answer 1st lines differ - expected: '499122177', found: '499122177910398850220911476'