結果

問題 No.623 fudan no modulus to tigau
ユーザー ayaoniayaoni
提出日時 2020-12-13 00:36:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 816 bytes
コンパイル時間 790 ms
コンパイル使用メモリ 81,628 KB
実行使用メモリ 84,728 KB
最終ジャッジ日時 2023-10-20 02:49:48
合計ジャッジ時間 4,605 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
82,568 KB
testcase_01 AC 90 ms
75,552 KB
testcase_02 AC 91 ms
75,556 KB
testcase_03 AC 90 ms
75,560 KB
testcase_04 AC 95 ms
75,556 KB
testcase_05 AC 49 ms
61,592 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
TAB = [(0,0,0)]*2+[tuple(MI()) for _ in range(N-1)]
Q = I()
X = LI()
mod = 998244353


def f(i,x):
    if i == 0:
        return 1
    if i == 1:
        return x
    t,a,b = TAB[i]
    if t == 1:
        res = f(a,x)+f(b,x)
    elif t == 2:
        res = a*f(b,x)
    else:
        res = f(a,x)*f(b,x)
    return res % mod


for x in X:
    print(f(N,x))
0