結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー k
提出日時 2020-09-03 02:21:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 548 bytes
コンパイル時間 2,028 ms
コンパイル使用メモリ 193,748 KB
最終ジャッジ日時 2025-01-14 03:56:29
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 MLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

const long long MOD = 998244353;

int n, q;
int a[6060];
long long dp[6060][6060];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> q;
  REP (i, n) cin >> a[i];

  dp[0][0] = 1;
  REP (i, n) REP (j, n) {
    dp[i+1][j] += dp[i][j] * (a[i] - 1) % MOD;
    dp[i+1][j] %= MOD;
    dp[i+1][j+1] += dp[i][j];
    dp[i+1][j+1] %= MOD;
  }

  while (q--) {
    int b;
    cin >> b;
    cout << dp[n][b] << endl;
  }
  
  return 0;
}
0