QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#584607 | #9376. Game | yehuadonghui | WA | 0ms | 3564kb | C++20 | 1.4kb | 2024-09-23 15:44:40 | 2024-09-23 15:44:41 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using i64 = long long;
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0);
#define all(x) x.begin(),x.end()
#define all2(x) x.begin()+1,x.end()
#define pi pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define si set<int>
#define mi map<int,int>
#define mc map<char,int>
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define fi first
#define sc second
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
const int mod = 998244353;
int qmi(int a,int b,int q)
{
int ans=1;
while(b){
if(b&1){
ans=ans*a%q;
}
a=a*a%q;
b>>=1;
}
return ans%q;
}
int p0,p1,p2,p3;
int dfs(int x,int y){
if(x==y){
return p0*p3%mod;
}
if(x<y){
int k=y/x;
if(y%x==0){
k--;
}
return dfs(x,y-k*x)%mod*qmi(p0*p3%mod,k,mod)%mod;
}
else {
int k=x/y;
if(x%y==0){
k--;
}
return dfs(y,x-k*y)%mod*qmi(p1*p3%mod,k,mod)%mod;
}
}
void solve()
{
int x,y;
cin>>x>>y;
int a,b,c;
cin>>a>>b>>c;
p0=a*qmi(c,mod-2,mod)%mod;
p1=b*qmi(c,mod-2,mod)%mod;
p2=(1-p0-p1+mod+mod)%mod;
p3=qmi((1-p2+mod)%mod,mod-2,mod)%mod;
cout<<dfs(x,y)%mod<<endl;
}
signed main()
{
IOS
int t;
cin>>t;
while(t--){
solve();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
499122177 910398850 50211691
result:
wrong answer 3rd lines differ - expected: '220911476', found: '50211691'