QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585371 | #9376. Game | Savior | WA | 0ms | 3708kb | C++20 | 964b | 2024-09-23 20:32:09 | 2024-09-23 20:32:09 |
Judging History
answer
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
#define int long long
using ll = long long;
const int inf = 2e15+7, N = 3e5+5, mod = 998244353;
typedef pair<int, int> P;
int qpow(int a,int b,int c){
int ans=1;
while(b){
if(b&1) ans=ans*a%c;
b>>=1,a=a*a%c;
}
return ans;
}
int x,y,a,b,c;
int dfs(int n,int m){
if(n<=0) return 0;
if(m<=0) return 1;
if(n<m){
int k=m/n;if(m%n==0) k-=1;
return dfs(n,m%n)*qpow(qpow(a,k,mod),mod-2,mod)%mod;
}
else{
int k=n/m;if(n%m==0) k-=1;
return dfs(n%m,m)*qpow(qpow(b,k,mod),mod-2,mod)%mod;
}
}
void solve(){
cin>>x>>y>>a>>b>>c;
int s=qpow(a+b,mod-2,mod);
a=a*s%mod,b=b*s%mod;
cout<<dfs(x,y)<<endl;
return;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int t = 1;cin>>t;
while (t--)solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3708kb
input:
3 1 1 2 2 6 1 3 2 3 6 3 4 7 3 15
output:
0 748683271 0
result:
wrong answer 1st lines differ - expected: '499122177', found: '0'