結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー pionepione
提出日時 2020-05-30 00:09:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 174 ms / 2,000 ms
コード長 1,930 bytes
コンパイル時間 1,487 ms
コンパイル使用メモリ 166,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-06 06:34:10
合計ジャッジ時間 3,564 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 66 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 166 ms
4,380 KB
testcase_11 AC 38 ms
4,376 KB
testcase_12 AC 29 ms
4,376 KB
testcase_13 AC 39 ms
4,376 KB
testcase_14 AC 42 ms
4,376 KB
testcase_15 AC 113 ms
4,376 KB
testcase_16 AC 19 ms
4,376 KB
testcase_17 AC 21 ms
4,380 KB
testcase_18 AC 102 ms
4,376 KB
testcase_19 AC 37 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 79 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 174 ms
4,376 KB
testcase_26 AC 172 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 998244353;
const ll LINF = 1e18;

ll dp[6001];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,q; cin>>n>>q;
  vll a(n);
  rep(i,n) cin>>a[i];
  vll b(q);
  rep(i,q) cin>>b[i];
  
  rep(i,n) dp[0]=1;
  rep(i,n){
    rrep(j,n){
      (dp[j+1]+=dp[j])%=MOD;
      (dp[j]*=(a[i]-1+MOD)%MOD)%=MOD;
    }
  }
  
  rep(i,q){
    cout<<dp[b[i]]<<endl;
  }
  
}
0