QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#587110#9376. GameDINGWA 0ms3628kbC++171.1kb2024-09-24 17:37:492024-09-24 17:37:50

Judging History

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

  • [2024-09-24 17:37:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-09-24 17:37:49]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=998244353;
int quick(int a,int n){
    int res=1;
    while(n){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
    }
    return res%mod;
}
int x,y,a0,a1,b,ni;
int dfs(int x,int y,int ans ){
    if(x==0)return 1;
    if(y==0)return quick(a0,x)*quick(ni,x)%mod;
    if(x==y)return a0*ni%mod;
    if(x>y){
        int ci=x/y;
        x=x%y;
        ans=ans%mod+(quick(a0+a1,ci)-quick(a1,ci)+mod)%mod*quick(ni,ci)%mod*dfs(x,y,ans)%mod;
       // cout<<ans<<"!"<<endl;
      //  return ans;
    }
    else if(x<y){
        int ci=y/x;
        y=y%x;
        ans=ans%mod+quick(a0,ci)*quick(ni,ci)%mod*dfs(x,y,ans)%mod;
        // cout<<ans<<"?"<<endl;
       // return ans;
    }
    return ans;
}
void solve(){
    cin>>x>>y>>a0>>a1>>b;
    int tem=a1+a0;
    a1=a1/__gcd(tem,a1);
    a0=a0/__gcd(tem,a0);
    ni=quick(a0+a1,mod-2);
    int ans=dfs(x,y,0);
    cout<<ans%mod<<endl;
}
signed main(){
    int t;
    cin>>t;
   // cout<<quick(2,10)<<endl;
    while(t--){
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:

499122177
364159540
220911476

result:

wrong answer 2nd lines differ - expected: '910398850', found: '364159540'