結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2020-05-29 22:09:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,298 bytes |
| コンパイル時間 | 1,800 ms |
| コンパイル使用メモリ | 173,220 KB |
| 実行使用メモリ | 288,372 KB |
| 最終ジャッジ日時 | 2024-11-06 05:02:03 |
| 合計ジャッジ時間 | 5,926 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 3 |
| other | MLE * 24 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;
static const long long mod = 998244353;
struct mint {
long long x;
mint(ll x = 0):x(x%mod) {}
mint& operator+=(const mint a) {
(x += a.x) %= mod;
return *this;
}
mint& operator-=(const mint a) {
(x += mod-a.x) %= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint ret(*this);
return ret += a;
}
mint operator-(const mint a) const {
mint ret(*this);
return ret -= a;
}
mint operator*(const mint a) const {
mint ret(*this);
return ret *= a;
}
mint pow(ll t) const {
if(t==0) return mint(1);
mint a = pow(t>>1);
a *= a;
if(t&1) a *= *this;
return a;
}
//for prime mod
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint ret(*this);
return ret /= a;
}
};
ostream &operator<<(ostream& os, const mint& x) {
os << x.x;
return os;
}
class modutils {
vector<mint> fact, invfact;
public:
modutils(int n = 200005):fact(n+1),invfact(n+1) {
fact[0] = 1;
for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
invfact[n] = fact[n].inv();
for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
}
mint pow(mint x, ll n) {
return x.pow(n);
}
mint comb(ll n, ll k) {
if(n<0 || k<0 || n<k) return 0;
return fact[n] * invfact[k] * invfact[n-k];
}
mint perm(ll n, ll k) {
if(n<0 || k<0 || n<k) return 0;
return fact[n] * invfact[n-k];
}
mint fac(ll n) {
return fact[n];
}
};
modutils mutil;
mint dp[6005][6005];
int main(){
int N, Q;
cin >> N >> Q;
vector<int> v;
rep(i,N){
int a;
cin >> a;
v.push_back(a);
}
dp[0][0] = 1;
rep(i,N){
rep(j,N+1){
dp[i+1][j] += dp[i][j]*(v[i]-1);
dp[i+1][j+1] += dp[i][j];
}
}
rep(i,Q){
int b;
cin >> b;
cout << dp[N][b] << endl;
}
return 0;
}
どらら