結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-10-12 15:06:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 340 ms / 2,000 ms |
コード長 | 447 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 82,004 KB |
実行使用メモリ | 77,532 KB |
最終ジャッジ日時 | 2024-07-20 18:00:36 |
合計ジャッジ時間 | 4,263 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
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)