結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー wattaiheiwattaihei
提出日時 2020-05-29 21:54:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-23 21:53:20
合計ジャッジ時間 2,970 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,712 KB
testcase_01 AC 34 ms
51,968 KB
testcase_02 AC 34 ms
51,840 KB
testcase_03 AC 38 ms
51,968 KB
testcase_04 AC 36 ms
51,712 KB
testcase_05 AC 34 ms
51,840 KB
testcase_06 AC 34 ms
51,584 KB
testcase_07 AC 33 ms
51,968 KB
testcase_08 AC 93 ms
76,416 KB
testcase_09 AC 43 ms
58,112 KB
testcase_10 AC 153 ms
76,672 KB
testcase_11 AC 80 ms
76,160 KB
testcase_12 AC 75 ms
76,288 KB
testcase_13 AC 81 ms
76,288 KB
testcase_14 AC 82 ms
76,288 KB
testcase_15 AC 123 ms
76,544 KB
testcase_16 AC 82 ms
76,288 KB
testcase_17 AC 72 ms
76,416 KB
testcase_18 AC 115 ms
76,672 KB
testcase_19 AC 82 ms
76,544 KB
testcase_20 AC 40 ms
58,112 KB
testcase_21 AC 102 ms
76,288 KB
testcase_22 AC 40 ms
57,856 KB
testcase_23 AC 35 ms
51,712 KB
testcase_24 AC 35 ms
51,584 KB
testcase_25 AC 153 ms
76,544 KB
testcase_26 AC 159 ms
76,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod = 998244353

N, Q = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

dp = [1]
for i, a in enumerate(A):
    ndp = [0]*(i+2)
    ndp[0] = dp[0]*(a-1) % mod
    ndp[i+1] = 1
    for j in range(1, i+1):
        ndp[j] = (dp[j]*(a-1) + dp[j-1]) % mod
    dp = ndp

for b in B:
    print(dp[b])
0