結果

問題 No.623 fudan no modulus to tigau
ユーザー ああいいああいい
提出日時 2022-05-19 09:55:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 466 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 81,588 KB
実行使用メモリ 61,712 KB
最終ジャッジ日時 2023-10-17 18:07:22
合計ジャッジ時間 2,140 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
59,520 KB
testcase_01 AC 44 ms
59,520 KB
testcase_02 AC 45 ms
59,520 KB
testcase_03 AC 44 ms
59,520 KB
testcase_04 AC 44 ms
59,520 KB
testcase_05 AC 43 ms
59,504 KB
testcase_06 AC 42 ms
59,504 KB
testcase_07 AC 43 ms
59,516 KB
testcase_08 AC 50 ms
61,712 KB
testcase_09 AC 44 ms
59,520 KB
testcase_10 AC 45 ms
59,528 KB
testcase_11 AC 45 ms
59,528 KB
testcase_12 AC 38 ms
53,288 KB
testcase_13 AC 37 ms
53,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P = 998244353

n = int(input())
poly = []
for _ in range(n - 1):
    t,a,b = map(int,input().split())
    poly.append((t,a,b))
q = int(input())
x = list(map(int,input().split()))

for u in x:
    dat = [0] * 2
    dat[0] = 1
    dat[1] = u
    for t,a,b in poly:
        if t == 1:
            dat.append((dat[a] + dat[b]) % P)
        elif t == 2:
            dat.append((a * dat[b]) % P)
        else:
            dat.append(dat[a] * dat[b] % P)
    print(dat[n])
0