結果

問題 No.3682 きあいのハチマキ
コンテスト
ユーザー bolero
提出日時 2026-09-05 15:34:45
言語 C++23
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,763 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,848 ms
コンパイル使用メモリ 380,948 KB
実行使用メモリ 9,772 KB
最終ジャッジ日時 2026-09-05 15:34:52
合計ジャッジ時間 5,199 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#if __has_include(<pch/all.h>)
#include <pch/all.h>
#else
#include <bits/stdc++.h>
#include <atcoder/all>
#endif

using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No")
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename Container>
void printVector(const Container &v, char delimiter = ' ')
{
    for (auto itr = v.begin(); itr != v.end(); itr++)
    {
        if (itr != v.begin())
        {
            cout << delimiter;
        }
        cout << *itr;
    }
    cout << endl;
}

template <typename Container>
void printlnVector(const Container &v)
{
    printVector(v, '\n');
}

void solve()
{
    vector<long long> H(2), A(2), S(2);
    rep(i, 2)
    {
        cin >> H[i] >> A[i] >> S[i];
    }

    vector<long long> k = {
        (H[1] + A[0] - 1) / A[0],
        (H[0] + A[1] - 1) / A[1],
    };

    atcoder::modint998244353 one_11 = atcoder::modint998244353{1} / atcoder::modint998244353{11};
    atcoder::modint998244353 ten_11 = atcoder::modint998244353{10} / atcoder::modint998244353{11};

    atcoder::modint998244353 one_10 = atcoder::modint998244353{1} / atcoder::modint998244353{10};
    atcoder::modint998244353 nine_10 = atcoder::modint998244353{9} / atcoder::modint998244353{10};

    long long delta_k = max(k[0], k[1]) - min(k[0], k[1]);

    atcoder::modint998244353 ans = 1;
    if (S[0] > S[1])
    {
        if (k[0] <= k[1])
        {
            // cout << "???" << endl;
            ans = atcoder::modint998244353{1} - one_11 / atcoder::modint998244353{10}.pow(delta_k);
        }
        else
        {
            // cout << "!!!" << endl;
            ans = atcoder::modint998244353{1} - ten_11 / atcoder::modint998244353{10}.pow(delta_k);
        }
    }
    if (S[0] < S[1])
    {
        if (k[0] <= k[1])
        {
            // cout << "!!!" << endl;
            ans = atcoder::modint998244353{1} - ten_11 / atcoder::modint998244353{10}.pow(delta_k);
        }
        else
        {
            // cout << "???" << endl;
            ans = atcoder::modint998244353{1} - one_11 / atcoder::modint998244353{10}.pow(delta_k);
        }
    }
    if (S[0] == S[1])
    {
        if (k[0] <= k[1])
        {
            ans = atcoder::modint998244353{1} - atcoder::modint998244353{1} / atcoder::modint998244353{10}.pow(delta_k) / 2;
        }
        else
        {
            ans = atcoder::modint998244353{1} - (atcoder::modint998244353{9} / atcoder::modint998244353{10}).pow(delta_k) / 2;
        }
    }
    cout << ans.val() << endl;
}

int main()
{
    int T = 1;
    cin >> T;

    while (T--)
    {
        solve();
    }

    return 0;
}
0