結果
問題 | No.623 fudan no modulus to tigau |
ユーザー | nebukuro09 |
提出日時 | 2018-01-17 09:25:59 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 839 bytes |
コンパイル時間 | 720 ms |
コンパイル使用メモリ | 113,328 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-03 18:10:43 |
合計ジャッジ時間 | 1,530 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 1 ms
4,380 KB |
testcase_08 | AC | 1 ms
4,380 KB |
testcase_09 | AC | 1 ms
4,380 KB |
testcase_10 | AC | 1 ms
4,376 KB |
testcase_11 | AC | 1 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,380 KB |
testcase_13 | AC | 1 ms
4,376 KB |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; immutable long MOD = 998244353; void main() { auto N = readln.chomp.to!int; auto F = (N-1).iota.map!(_ => readln.split.map!(to!int).array).array; auto Q = readln.chomp.to!int; auto X = readln.split.map!(to!long).array; foreach (x; X) { auto Y = new long[](N+1); Y[0] = 1; Y[1] = x; foreach (i, f; F.enumerate) { if (f[0] == 1) { Y[i+2] = (Y[f[1]] + Y[f[2]]) % MOD; } else if (f[0] == 2) { Y[i+2] = (f[1] * Y[f[2]]) % MOD; } else { Y[i+2] = Y[f[1]] * Y[f[2]] % MOD; } } Y.back.writeln; } }