結果
問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
ユーザー |
|
提出日時 | 2020-05-29 21:54:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 727 bytes |
コンパイル時間 | 1,586 ms |
コンパイル使用メモリ | 169,468 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-06 04:08:07 |
合計ジャッジ時間 | 3,074 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#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; }