QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591697#9376. GamelamkappaWA 0ms3652kbC++201.3kb2024-09-26 17:14:272024-09-26 17:14:38

Judging History

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

  • [2024-09-26 17:14:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2024-09-26 17:14:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64 = long long;

constexpr i64 M = 998244353;

i64 qpow(i64 x, i64 y=M-2){
    i64 res = 1;
    while(y){
        if(y & 1) res = res*x%M;
        x = x*x%M;
        y >>= 1;
    }
    return res;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    cin >> T;
    while(T--){
        i64 x, y; cin >> x >> y;
        i64 a0, a1, b; cin >> a0 >> a1 >> b;
        i64 p0 = a0 * qpow(a0+a1) % M;
        i64 p1 = a1 * qpow(a0+a1) % M;

        auto T = make_pair(x, y);
        i64 px = 0, py = 0, pl = 1;
        do{
            if(x > y){
                auto k = (x - 1) / y;
                x -= k * y;
                // y *= 2;
                px = (px + pl * qpow(p0, k)) % M;
                pl = pl * qpow(p1, k) % M;
            }else if(x < y){
                auto k = (y - 1) / x;
                y -= k * x;
                // x *= 2;
                py = (py + pl * qpow(p1, k)) % M;
                pl = pl * qpow(p0, k) % M;
            }else{
                px = (px + pl * p0) % M;
                py = (py + pl * p1) % M;
                break;
            }
        }while(1);

        cout << px << '\n';
    }

    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

499122177
910398850
218914987

result:

wrong answer 3rd lines differ - expected: '220911476', found: '218914987'