結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー c-yanc-yan
提出日時 2020-05-30 09:19:27
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 76,948 KB
最終ジャッジ日時 2023-08-07 00:09:41
合計ジャッジ時間 5,218 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,240 KB
testcase_01 AC 69 ms
71,088 KB
testcase_02 AC 70 ms
71,164 KB
testcase_03 AC 73 ms
71,048 KB
testcase_04 AC 69 ms
71,252 KB
testcase_05 AC 68 ms
71,076 KB
testcase_06 AC 70 ms
71,248 KB
testcase_07 AC 69 ms
71,196 KB
testcase_08 AC 170 ms
76,760 KB
testcase_09 AC 73 ms
75,872 KB
testcase_10 AC 309 ms
76,780 KB
testcase_11 AC 132 ms
76,756 KB
testcase_12 AC 123 ms
76,812 KB
testcase_13 AC 136 ms
76,780 KB
testcase_14 AC 136 ms
76,948 KB
testcase_15 AC 237 ms
76,764 KB
testcase_16 AC 107 ms
76,856 KB
testcase_17 AC 112 ms
76,768 KB
testcase_18 AC 223 ms
76,588 KB
testcase_19 AC 129 ms
76,840 KB
testcase_20 AC 74 ms
75,896 KB
testcase_21 AC 191 ms
76,612 KB
testcase_22 AC 73 ms
75,788 KB
testcase_23 AC 69 ms
71,152 KB
testcase_24 AC 69 ms
71,284 KB
testcase_25 AC 330 ms
76,784 KB
testcase_26 AC 318 ms
76,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

dp = [0] * (N + 1)
dp[1] = 1
dp[0] = A[0] - 1
for a in A[1:]:
    for i in range(N - 1, -1, -1):
        dp[i + 1] += dp[i]
        dp[i + 1] %= 998244353
        dp[i] *= a - 1
        dp[i] %= 998244353

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