結果
問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
ユーザー |
![]() |
提出日時 | 2020-05-29 22:11:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 175 ms / 2,000 ms |
コード長 | 714 bytes |
コンパイル時間 | 1,703 ms |
コンパイル使用メモリ | 166,892 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 05:04:48 |
合計ジャッジ時間 | 3,631 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> #define REP(i, n) for(int i = 0; (i) < (n); (i)++) using namespace std; int main() { int N, Q; cin >> N >> Q; long A[7000]; REP(i, N) cin >> A[i]; long B[7000]; REP(i, Q) cin >> B[i]; long mod = 998244353; long dp1[7000], dp2[7000]; REP(i, N+1) dp1[i] = 0l; dp1[0] = A[0]-1l; dp1[1] = 1l; REP(i, N-1){ REP(j, N+1) dp2[j] = 0l; REP(j, N+1){ dp2[j] += (dp1[j] * (A[i+1] - 1l)) % mod; dp2[j] %= mod; } REP(j, N){ dp2[j+1] += dp1[j]; dp2[j+1] %= mod; } REP(j, N+1) dp1[j] = dp2[j]; } REP(i, Q) cout << dp1[B[i]] << endl; return 0; }