結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー c-yanc-yan
提出日時 2020-07-30 05:16:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 223 ms / 2,000 ms
コード長 372 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 77,112 KB
最終ジャッジ日時 2023-09-14 21:36:04
合計ジャッジ時間 4,708 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,180 KB
testcase_01 AC 71 ms
71,260 KB
testcase_02 AC 70 ms
71,380 KB
testcase_03 AC 69 ms
71,320 KB
testcase_04 AC 73 ms
71,316 KB
testcase_05 AC 68 ms
71,228 KB
testcase_06 AC 70 ms
71,384 KB
testcase_07 AC 70 ms
71,232 KB
testcase_08 AC 129 ms
77,008 KB
testcase_09 AC 74 ms
76,168 KB
testcase_10 AC 211 ms
77,024 KB
testcase_11 AC 112 ms
76,936 KB
testcase_12 AC 105 ms
77,016 KB
testcase_13 AC 114 ms
77,016 KB
testcase_14 AC 115 ms
77,072 KB
testcase_15 AC 171 ms
76,772 KB
testcase_16 AC 97 ms
76,976 KB
testcase_17 AC 99 ms
77,048 KB
testcase_18 AC 166 ms
77,028 KB
testcase_19 AC 113 ms
77,092 KB
testcase_20 AC 75 ms
76,048 KB
testcase_21 AC 146 ms
77,112 KB
testcase_22 AC 77 ms
76,140 KB
testcase_23 AC 72 ms
71,260 KB
testcase_24 AC 72 ms
71,260 KB
testcase_25 AC 216 ms
77,024 KB
testcase_26 AC 223 ms
77,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# PyPy でのみ AC
N, Q = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

m = 998244353

dp = [0] * (N + 1)
dp[1] = 1
dp[0] = A[0] - 1
for i in range(1, N):
    for j in range(i, -1, -1):
        dp[j + 1] += dp[j]
        dp[j + 1] %= m
        dp[j] *= A[i] - 1
        dp[j] %= m
print(*(dp[b] for b in B), sep='\n')
0