結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー NoneNone
提出日時 2021-02-26 01:04:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 331 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 68,252 KB
最終ジャッジ日時 2024-04-09 03:38:35
合計ジャッジ時間 3,364 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,104 KB
testcase_01 AC 35 ms
53,696 KB
testcase_02 AC 35 ms
52,744 KB
testcase_03 AC 36 ms
52,736 KB
testcase_04 AC 35 ms
52,952 KB
testcase_05 AC 36 ms
52,308 KB
testcase_06 AC 36 ms
52,420 KB
testcase_07 AC 35 ms
53,176 KB
testcase_08 AC 88 ms
66,056 KB
testcase_09 AC 43 ms
58,852 KB
testcase_10 AC 151 ms
67,984 KB
testcase_11 AC 73 ms
67,208 KB
testcase_12 AC 68 ms
65,772 KB
testcase_13 AC 74 ms
67,464 KB
testcase_14 AC 75 ms
65,776 KB
testcase_15 AC 115 ms
67,304 KB
testcase_16 AC 62 ms
65,176 KB
testcase_17 AC 63 ms
65,144 KB
testcase_18 AC 111 ms
67,696 KB
testcase_19 AC 72 ms
66,136 KB
testcase_20 AC 41 ms
58,336 KB
testcase_21 AC 96 ms
67,132 KB
testcase_22 AC 41 ms
59,044 KB
testcase_23 AC 36 ms
53,020 KB
testcase_24 AC 36 ms
52,604 KB
testcase_25 AC 150 ms
68,252 KB
testcase_26 AC 150 ms
68,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
MOD = 998244353
N,Q=map(int, input().split())
A=list(map(int, input().split()))

dp=[0]*(N+1)
dp[0]=1
for k_max,a in enumerate(A,start=1):
    a-=1
    for k in range(k_max)[::-1]:
        dp[k+1]+=dp[k]*a
        dp[k+1]%=MOD

B=list(map(int, input().split()))
for k in B:
    print(dp[N-k])
0