QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#585371#9376. GameSaviorWA 0ms3708kbC++20964b2024-09-23 20:32:092024-09-23 20:32:09

Judging History

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

  • [2024-09-23 20:32:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3708kb
  • [2024-09-23 20:32:09]
  • 提交

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'