結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
![]() |
提出日時 | 2020-06-08 22:17:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 853 ms / 2,000 ms |
コード長 | 883 bytes |
コンパイル時間 | 2,129 ms |
コンパイル使用メモリ | 193,172 KB |
最終ジャッジ日時 | 2025-01-11 00:14:20 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i) #define rep(i, n) REP(i, 0, n) using namespace std; using ll = long long; using ld = long double; template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; } template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; } ll MOD = 998244353; int n, q, a[200000]; ll dp[2][6010]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> q; rep(i, n) cin >> a[i]; dp[0][0] = 1; rep(i, n) { rep(j, n+1) { dp[1][j] += dp[0][j]*(a[i]-1); dp[1][j] %= MOD; dp[1][j+1] += dp[0][j]; dp[1][j+1] %= MOD; } rep(j, n+1) dp[0][j] = dp[1][j], dp[1][j] = 0; } rep(qi, q) { int b; cin >> b; cout << dp[0][b] << '\n'; } return 0; }