結果
| 問題 |
No.3045 反復重み付き累積和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 22:58:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,204 bytes |
| コンパイル時間 | 4,731 ms |
| コンパイル使用メモリ | 259,264 KB |
| 実行使用メモリ | 16,720 KB |
| 最終ジャッジ日時 | 2025-02-28 22:59:57 |
| 合計ジャッジ時間 | 60,178 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 TLE * 1 -- * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
vector<mint> a(n);
for(int i = 0; i < n; i++){
int v;
cin >> v;
a[i] = mint::raw(v);
}
auto f = [&](int k, int x){
vector<mint> res(1, 1), tmp(n);
tmp[0] = 1;
for(int i = 0; i + 1 < n; i++) tmp[i + 1] = tmp[i] * mint::raw(k);
while(x){
if(x & 1){
res = convolution(res, tmp);
while(res.size() > n) res.pop_back();
}
x /= 2;
if(x){
tmp = convolution(tmp, tmp);
while(tmp.size() > n) tmp.pop_back();
}
}
return res;
};
while(q--){
int cmd;
cin >> cmd;
if(cmd == 1){
int k, x;
cin >> k >> x;
a = convolution(a, f(k, x));
while(a.size() > n) a.pop_back();
}else{
int x;
cin >> x;
cout << a[x - 1].val() << '\n';
}
}
}