結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー autumn-eel
提出日時 2020-05-29 21:28:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 166,040 KB
実行使用メモリ 168,320 KB
最終ジャッジ日時 2024-11-06 02:29:17
合計ジャッジ時間 3,971 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 WA * 19 MLE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

ll dp[7000][7000];
int a[7000];

int main(){
	int n,q;cin>>n>>q;
	rep(i,n)scanf("%d",&a[i]);
	dp[0][0]=1;
	rep(i,n)rep(j,n){
		if(dp[i][j]==0)continue;
		(dp[i+1][j+1]+=dp[i][j])%=MOD;
		(dp[i+1][j]+=dp[i][j]*(a[i]-1))%=MOD;
	}
	rep(i,q){
		int b;scanf("%d",&b);
		printf("%lld\n",dp[n][b]);
	}
}
0