結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー kappybarkappybar
提出日時 2020-05-29 21:54:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 165,472 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-23 21:52:15
合計ジャッジ時間 2,819 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 35 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 93 ms
5,376 KB
testcase_11 AC 21 ms
5,376 KB
testcase_12 AC 17 ms
5,376 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 AC 24 ms
5,376 KB
testcase_15 AC 63 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 12 ms
5,376 KB
testcase_18 AC 57 ms
5,376 KB
testcase_19 AC 20 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 44 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 95 ms
5,376 KB
testcase_26 AC 94 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
using vc = pair<ll,vector<ll>>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 998244353;

int main(){
    int n,q;
    cin >> n >> q;
    vector<ll> a(n),b(q);
    rep(i,n) cin >> a[i];
    rep(i,q) cin >> b[i];
    vector<ll> dp(n+1,0);
    dp[0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=n;j>=0;j--){
            if(j > 0) dp[j] = ((dp[j]*(a[i-1]-1))%MOD + dp[j-1])%MOD;
            else dp[j] = (dp[j]*(a[i-1]-1))%MOD;
        }
    }
    rep(i,q){
        cout << dp[b[i]] << '\n' ;
    }
    return 0;
}
0