結果
| 問題 | No.623 fudan no modulus to tigau |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-23 00:44:01 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 582 bytes |
| 記録 | |
| コンパイル時間 | 119 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 60,032 KB |
| 最終ジャッジ日時 | 2026-05-26 18:40:03 |
| 合計ジャッジ時間 | 1,424 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
#!/usr/bin/env python
def fc(funcs, n):
fc = [1, n]
for func in funcs:
if func[0] == 1:
fc.append((fc[func[1]]+fc[func[2]]) % 998244353)
elif func[0] == 2:
fc.append((func[1]*fc[func[2]]) % 998244353)
elif func[0] == 3:
fc.append((fc[func[1]]*fc[func[2]]) % 998244353)
return fc[-1]
n = int(input())
funcs = []
for i in range(n-1):
funcs.append([int(x) for x in input().split()])
q = int(input())
indats = [int(x) for x in input().split()]
for indat in indats:
print(fc(funcs, indat) % 998244353)