結果
問題 |
No.623 fudan no modulus to tigau
|
ユーザー |
![]() |
提出日時 | 2020-12-13 00:36:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 816 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,152 KB |
実行使用メモリ | 89,992 KB |
最終ジャッジ日時 | 2024-09-19 22:35:46 |
合計ジャッジ時間 | 4,296 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | AC * 6 TLE * 1 -- * 5 |
ソースコード
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))