結果

問題 No.623 fudan no modulus to tigau
ユーザー H3PO4H3PO4
提出日時 2020-10-13 09:17:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 455 bytes
コンパイル時間 1,044 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2023-09-27 23:59:34
合計ジャッジ時間 1,337 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,884 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 15 ms
7,824 KB
testcase_03 AC 14 ms
7,780 KB
testcase_04 AC 16 ms
7,888 KB
testcase_05 AC 16 ms
7,772 KB
testcase_06 AC 16 ms
7,796 KB
testcase_07 AC 16 ms
7,876 KB
testcase_08 AC 15 ms
7,788 KB
testcase_09 AC 16 ms
7,936 KB
testcase_10 AC 15 ms
7,928 KB
testcase_11 AC 15 ms
7,796 KB
testcase_12 AC 13 ms
7,872 KB
testcase_13 AC 14 ms
7,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
TAB = [tuple(map(int, input().split())) for _ in range(N - 1)]
Q = int(input())
X = map(int, input().split())
MOD = 998244353

for x in X:
    table = [1, x] + [0] * (N - 1)
    for i, (t, a, b) in enumerate(TAB, 2):
        if t == 1:
            table[i] = table[a] + table[b]
        elif t == 2:
            table[i] = a * table[b]
        else:
            table[i] = table[a] * table[b]
        table[i] %= MOD
    print(table[-1])
0