結果
問題 | No.623 fudan no modulus to tigau |
ユーザー |
|
提出日時 | 2017-12-23 00:44:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 582 bytes |
コンパイル時間 | 244 ms |
コンパイル使用メモリ | 82,496 KB |
実行使用メモリ | 60,628 KB |
最終ジャッジ日時 | 2024-12-17 14:22:32 |
合計ジャッジ時間 | 1,518 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
#!/usr/bin/env pythondef 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)