結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー 双六双六
提出日時 2020-08-11 05:03:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 385 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 68,960 KB
最終ジャッジ日時 2024-04-17 17:00:54
合計ジャッジ時間 3,894 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,372 KB
testcase_01 AC 38 ms
52,592 KB
testcase_02 AC 38 ms
52,732 KB
testcase_03 AC 39 ms
52,524 KB
testcase_04 AC 38 ms
52,944 KB
testcase_05 AC 37 ms
53,828 KB
testcase_06 AC 37 ms
52,092 KB
testcase_07 AC 39 ms
52,012 KB
testcase_08 AC 152 ms
66,052 KB
testcase_09 AC 41 ms
58,908 KB
testcase_10 AC 295 ms
68,960 KB
testcase_11 AC 108 ms
66,392 KB
testcase_12 AC 93 ms
66,032 KB
testcase_13 AC 106 ms
66,636 KB
testcase_14 AC 111 ms
66,284 KB
testcase_15 AC 217 ms
67,448 KB
testcase_16 AC 74 ms
65,984 KB
testcase_17 AC 80 ms
66,024 KB
testcase_18 AC 202 ms
67,784 KB
testcase_19 AC 104 ms
65,524 KB
testcase_20 AC 43 ms
58,820 KB
testcase_21 AC 166 ms
66,808 KB
testcase_22 AC 43 ms
58,224 KB
testcase_23 AC 37 ms
53,104 KB
testcase_24 AC 37 ms
53,072 KB
testcase_25 AC 300 ms
67,976 KB
testcase_26 AC 300 ms
68,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

con = 998244353

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, Q = getlist()
	A = getlist()
	B = getlist()
	DP = [0] * (N + 1)
	DP[0] = 1
	for i in range(N):
		for j in range(N - 1, -1, -1):
			DP[j + 1] += DP[j]
			DP[j + 1] %= con
			DP[j] = (DP[j] * (A[i] - 1)) % con

	for i in range(Q):
		print(DP[B[i]])

if __name__ == '__main__':
	main()
0