結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2020-05-29 22:37:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 2,000 ms |
| コード長 | 649 bytes |
| コンパイル時間 | 930 ms |
| コンパイル使用メモリ | 91,040 KB |
| 最終ジャッジ日時 | 2025-01-10 17:53:08 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
constexpr int P = 998244353;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<int> r(n + 1);
r[0] = 1;
for (int i = 0; i < n; i++) {
int a;
cin >> a;
for (int j = i; j >= 0; j--) {
r[j + 1] = (r[j + 1] + (ll)(a - 1) * r[j]) % P;
}
}
for (int i = 0; i < q; i++) {
int b;
cin >> b;
cout << r[n - b] << '\n';
}
return 0;
}
merom686