結果
問題 |
No.2966 Simple Plus Minus Problem
|
ユーザー |
|
提出日時 | 2024-11-16 17:08:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,554 ms / 2,567 ms |
コード長 | 1,009 bytes |
コンパイル時間 | 4,489 ms |
コンパイル使用メモリ | 257,880 KB |
最終ジャッジ日時 | 2025-02-25 04:45:15 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 54 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using mint = modint998244353; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<mint> tmp(1, 1), coef(n), c(n); for(int i = 0; i < n; i++){ int v; cin >> v; c[i] = v; } for(int i = 0; i < n; i += 2) coef[i] = 1; int ex = (k + 1) / 2; while(ex != 0){ if(ex & 1){ tmp = convolution(tmp, coef); while(tmp.size() > n) tmp.pop_back(); } coef = convolution(coef, coef); while(coef.size() > n) coef.pop_back(); ex /= 2; } if(k % 2 == 1){ for(int i = 1; i < n; i += 2){ c[i] = -c[i]; tmp[i] = tmp[i - 1]; } } auto ans = convolution(c, tmp); while(ans.size() > n) ans.pop_back(); for(int i = 0; i < n; i++){ cout << ans[i].val() << (i + 1 == n ? '\n' : ' '); } }