結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
|
提出日時 | 2020-09-03 02:26:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 152 ms / 2,000 ms |
コード長 | 650 bytes |
コンパイル時間 | 2,027 ms |
コンパイル使用メモリ | 194,052 KB |
最終ジャッジ日時 | 2025-01-14 03:56:39 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#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[2][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) { int cur = i&1; int nxt = i+1&1; fill(dp[nxt], dp[nxt] + n + 1, 0); REP (j, n) { dp[nxt][j] += dp[cur][j] * (a[i] - 1) % MOD; dp[nxt][j] %= MOD; dp[nxt][j+1] += dp[cur][j]; dp[nxt][j+1] %= MOD; } } while (q--) { int b; cin >> b; cout << dp[n&1][b] << endl; } return 0; }