結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー c-yanc-yan
提出日時 2020-06-21 09:33:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 376 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 76,860 KB
最終ジャッジ日時 2023-09-16 18:10:02
合計ジャッジ時間 4,655 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,224 KB
testcase_01 AC 71 ms
71,292 KB
testcase_02 AC 82 ms
71,360 KB
testcase_03 AC 70 ms
70,940 KB
testcase_04 AC 72 ms
71,284 KB
testcase_05 AC 69 ms
71,124 KB
testcase_06 AC 69 ms
71,356 KB
testcase_07 AC 70 ms
71,344 KB
testcase_08 AC 130 ms
76,652 KB
testcase_09 AC 76 ms
76,128 KB
testcase_10 AC 210 ms
76,832 KB
testcase_11 AC 107 ms
76,860 KB
testcase_12 AC 100 ms
76,728 KB
testcase_13 AC 107 ms
76,804 KB
testcase_14 AC 108 ms
76,852 KB
testcase_15 AC 166 ms
76,420 KB
testcase_16 AC 93 ms
76,744 KB
testcase_17 AC 95 ms
76,548 KB
testcase_18 AC 160 ms
76,628 KB
testcase_19 AC 108 ms
76,728 KB
testcase_20 AC 75 ms
76,088 KB
testcase_21 AC 142 ms
76,764 KB
testcase_22 AC 83 ms
75,916 KB
testcase_23 AC 72 ms
71,068 KB
testcase_24 AC 73 ms
70,940 KB
testcase_25 AC 214 ms
76,764 KB
testcase_26 AC 215 ms
76,700 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('\n'.join(str(dp[b]) for b in B))
0