結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー qibqib
提出日時 2022-10-24 17:49:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 86,492 KB
実行使用メモリ 78,292 KB
最終ジャッジ日時 2023-09-15 18:58:27
合計ジャッジ時間 5,565 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,148 KB
testcase_01 AC 73 ms
71,244 KB
testcase_02 AC 73 ms
71,044 KB
testcase_03 AC 73 ms
70,852 KB
testcase_04 AC 72 ms
71,060 KB
testcase_05 AC 71 ms
71,036 KB
testcase_06 AC 72 ms
71,160 KB
testcase_07 AC 71 ms
71,200 KB
testcase_08 AC 196 ms
77,688 KB
testcase_09 AC 77 ms
75,724 KB
testcase_10 AC 265 ms
77,636 KB
testcase_11 AC 131 ms
77,640 KB
testcase_12 AC 120 ms
77,484 KB
testcase_13 AC 131 ms
77,680 KB
testcase_14 AC 133 ms
77,700 KB
testcase_15 AC 204 ms
77,440 KB
testcase_16 AC 108 ms
77,468 KB
testcase_17 AC 111 ms
77,376 KB
testcase_18 AC 197 ms
77,520 KB
testcase_19 AC 128 ms
77,288 KB
testcase_20 AC 78 ms
76,020 KB
testcase_21 AC 170 ms
77,316 KB
testcase_22 AC 77 ms
76,020 KB
testcase_23 AC 71 ms
70,872 KB
testcase_24 AC 72 ms
71,144 KB
testcase_25 AC 266 ms
77,824 KB
testcase_26 AC 267 ms
78,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n, q = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [(a[0] - 1) % MOD, 1, 0]
for i in range(1, n):
	ndp = [0 for _ in range(i + 3)]
	ndp[0] = (dp[0] * (a[i] - 1)) % MOD
	for j in range(1, i + 2):
		ndp[j] = (dp[j] * (a[i] - 1) + dp[j - 1]) % MOD
	dp = ndp

for i in range(q):
  print(dp[b[i]])
0