結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー Haa
提出日時 2020-05-29 21:37:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 616 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 172,900 KB
実行使用メモリ 285,056 KB
最終ジャッジ日時 2024-11-06 02:50:59
合計ジャッジ時間 4,326 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 MLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 998244353;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

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