結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー trineutron
提出日時 2020-05-29 22:20:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 2,315 ms
コンパイル使用メモリ 195,700 KB
最終ジャッジ日時 2025-01-10 17:42:04
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int64_t mod = 998244353;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n), b(q);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < q; i++) {
        cin >> b.at(i);
    }
    vector<int64_t> ans(n + 1);
    ans.at(0) = 1;
    for (int i = 0; i < n; i++) {
        for (int j = n; j > 0; j--) {
            ans.at(j) += ans.at(j - 1) * (a.at(i) - 1);
            ans.at(j) %= mod;
        }
    }
    for (int i = 0; i < q; i++) {
        cout << ans.at(n - b.at(i)) << endl;
    }
}
0