結果

問題 No.3682 きあいのハチマキ
コンテスト
ユーザー 👑 loop0919
提出日時 2026-07-15 00:21:25
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 318 ms / 2,000 ms
+ 943µs
コード長 1,042 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 95,948 KB
実行使用メモリ 95,568 KB
最終ジャッジ日時 2026-09-05 12:39:48
合計ジャッジ時間 2,425 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from fractions import Fraction

MOD = 998244353


def power(p, e):
    return pow(p, e, MOD)


# def power(p, e):
#     if e < 0:
#         return Fraction(1, power(p, -e))
#     return pow(p, e)


def solve():
    H1, A1, S1, H2, A2, S2 = [int(s) for s in input().split()]

    cnt1 = (H1 - 1) // A2
    cnt2 = (H2 - 1) // A1

    min_times = min(cnt1, cnt2)

    cnt1 -= min_times
    cnt2 -= min_times

    ans = 0

    if cnt1 > cnt2:
        ans += 1 - power(10, -cnt1)

    p = power(10, -max(cnt1, cnt2))

    if S1 > S2:
        ans += p * 9 * power(10, -1) * power(1 - power(100, -1), -1)
    elif S1 < S2:
        ans += p * 9 * power(100, -1) * power(1 - power(100, -1), -1)
    else:
        ans += p * power(2, -1)

    ans %= MOD

    print(ans)


# dp[n] = 1/10 * 9/10 * dp[n+1]
# dp[n] = 9/100 dp[n+1]

# x = 1/2 * (1/10 * 9/10 + 1/10 * 1/10 * x) + 1/2 * (9/10 + 1/10 * 1/10 * x)
# x = 9/100 + 1/100 * x
# 99/100 * x = 9/100
# x = 1/11


if __name__ == "__main__":
    T = int(input())

    for _ in range(T):
        solve()
0