結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define INF_LL 100000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<double, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

int dp[6001][6001];

signed main() {
    int n, q;
    cin >> n >> q;
    vl a(n);
    rep(i, n) cin >> a[i];
    dp[0][0] = 1;
    rep(i, n) rep(j, n) {
        dp[i + 1][j + 1] += dp[i][j];
        dp[i + 1][j] += (ll)dp[i][j] * (a[i] - 1);
        dp[i + 1][j + 1] %= MOD;
        dp[i + 1][j] %= MOD;
    }
    rep(i, q) {
        int b;
        cin >> b;
        cout << dp[n][b] << endl;
    }
    return 0;
}
0