結果

問題 No.623 fudan no modulus to tigau
ユーザー Eki1009Eki1009
提出日時 2020-09-14 01:55:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 7,940 KB
最終ジャッジ日時 2023-09-04 00:23:20
合計ジャッジ時間 1,359 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,840 KB
testcase_01 AC 18 ms
7,940 KB
testcase_02 AC 17 ms
7,800 KB
testcase_03 AC 17 ms
7,936 KB
testcase_04 AC 17 ms
7,940 KB
testcase_05 AC 17 ms
7,808 KB
testcase_06 AC 18 ms
7,812 KB
testcase_07 AC 18 ms
7,940 KB
testcase_08 AC 18 ms
7,836 KB
testcase_09 AC 18 ms
7,904 KB
testcase_10 AC 17 ms
7,840 KB
testcase_11 AC 17 ms
7,796 KB
testcase_12 AC 16 ms
7,824 KB
testcase_13 AC 16 ms
7,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n = int(input())
TAB = [list(map(int, input().split())) for _ in range(n-1)]
q = int(input())
X = list(map(int, input().split()))
for x in X:
    F = [1, x]
    for t, a, b in TAB:
        if t == 1:
            F.append(F[a] + F[b])
        if t == 2:
            F.append(a * F[b])
        if t == 3:
            F.append(F[a] * F[b])
        F[-1] %= mod
    print(F[-1])
0