結果

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

ソースコード

diff #

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

constexpr ll MOD = 998244353;

ll dp[6060][6060];

int main() {
  int n, q, b;
  cin >> n >> q;
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];

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

  rep(i, 0, q) {
    cin >> b;
    cout << dp[n][b] << '\n';
  }
  return 0;
}
0