結果
| 問題 | No.3682 きあいのハチマキ |
| コンテスト | |
| ユーザー |
dokukuma
|
| 提出日時 | 2026-09-05 15:04:39 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,760 bytes |
| 記録 | |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 95,944 KB |
| 実行使用メモリ | 93,776 KB |
| 最終ジャッジ日時 | 2026-09-05 15:04:43 |
| 合計ジャッジ時間 | 2,096 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 2 |
ソースコード
import sys, time, random, heapq, math, itertools, copy
from collections import deque, Counter, defaultdict
from sortedcontainers import SortedSet, SortedList
from bisect import bisect, bisect_left, bisect_right
import heapq as hq
from functools import cache, cmp_to_key
def debug(*x):print('debug:',*x, file=sys.stderr)
sys.setrecursionlimit(300000)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353
dir = [(0, 1), (0, -1), (1, 0), (-1, 0)]
T = ii()
for _ in range(T):
Hc, Ac, Sc, Hg, Ag, Sg = mi()
# 死ぬ直前のターンまでスキップ?
t = min((Hc-1)//Ag, (Hg-1)//Ac)
Hc -= t * Ag
Hg -= t * Ac
debug(t)
debug(Hc, Hg, Ac, Ag)
# 水色が後一回で倒れるなら,1/10を耐えた後1/2勝負で勝つ
if Hc - Ag <= 0:
rest = (Hg-1)//Ac
ans = pow(10, -rest, mod) # あと一回まで追い込む
if Sc > Sg:
# 9/10 + 1/10*1/10*9/10 + ... = 10/11
ans *= 10 * pow(11, -1, mod)
ans %= mod
elif Sc < Sg:
ans *= pow(11, -1, mod)
else:
ans *= pow(2, -1, mod)
else:
# 水色が優勢なら,上記の余事象(セルみたい)
Hc, Ac, Sc, Hg, Ag, Sg = Hg, Ag, Sg, Hc, Ac, Sc
rest = (Hg-1)//Ac
ans = pow(10, -rest, mod) # あと一回まで追い込む
if Sc > Sg:
# 9/10 + 1/10*1/10*9/10 + ... = 10/11
ans *= 10 * pow(11, -1, mod)
ans %= mod
elif Sc < Sg:
ans *= pow(11, -1, mod)
else:
ans *= pow(2, -1, mod)
ans =1 - ans
ans %= mod
print(ans)
dokukuma