結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー brthyyjpbrthyyjp
提出日時 2020-10-12 15:06:01
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 86,880 KB
実行使用メモリ 79,560 KB
最終ジャッジ日時 2023-09-27 23:39:35
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,096 KB
testcase_01 AC 61 ms
71,276 KB
testcase_02 AC 60 ms
71,396 KB
testcase_03 AC 62 ms
71,284 KB
testcase_04 AC 60 ms
71,156 KB
testcase_05 AC 62 ms
71,352 KB
testcase_06 AC 62 ms
71,356 KB
testcase_07 AC 61 ms
71,196 KB
testcase_08 AC 167 ms
77,640 KB
testcase_09 AC 65 ms
75,928 KB
testcase_10 AC 306 ms
78,864 KB
testcase_11 AC 130 ms
77,148 KB
testcase_12 AC 118 ms
77,396 KB
testcase_13 AC 129 ms
77,484 KB
testcase_14 AC 130 ms
77,548 KB
testcase_15 AC 232 ms
78,100 KB
testcase_16 AC 98 ms
77,420 KB
testcase_17 AC 103 ms
77,584 KB
testcase_18 AC 224 ms
78,056 KB
testcase_19 AC 128 ms
77,256 KB
testcase_20 AC 64 ms
75,824 KB
testcase_21 AC 184 ms
77,932 KB
testcase_22 AC 67 ms
76,456 KB
testcase_23 AC 62 ms
71,344 KB
testcase_24 AC 62 ms
71,328 KB
testcase_25 AC 321 ms
79,360 KB
testcase_26 AC 312 ms
79,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, q = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mod = 998244353

dp = [0]*(n+1)
dp[0] = A[0]-1
dp[1] = 1
for i in range(1, n):
    temp = [0]*(n+1)
    for j in range(n+1):
        if j == 0:
            temp[j] = dp[j]*(A[i]-1)
            temp[j] %= mod
        else:
            temp[j] = dp[j-1]+dp[j]*(A[i]-1)
            temp[j] %= mod
    dp = temp

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