結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー qib
提出日時 2022-10-24 17:45:01
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 417 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 81,584 KB
実行使用メモリ 358,992 KB
最終ジャッジ日時 2024-07-02 20:47:36
合計ジャッジ時間 6,073 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 MLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

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

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

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