結果
| 問題 | No.1145 Sums of Powers |
| コンテスト | |
| ユーザー |
👑 potato167
|
| 提出日時 | 2025-03-17 03:24:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,998 bytes |
| コンパイル時間 | 2,786 ms |
| コンパイル使用メモリ | 121,192 KB |
| 実行使用メモリ | 16,804 KB |
| 最終ジャッジ日時 | 2025-03-17 03:24:11 |
| 合計ジャッジ時間 | 4,902 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 6 |
ソースコード
#line 2 "/Users/Shared/po167_library/fps/FPS_log.hpp"
#include <vector>
#line 3 "/Users/Shared/po167_library/fps/FPS_differetial.hpp"
namespace po167{
// return f'
template <class T>
std::vector<T> FPS_differential(std::vector<T> f){
if (f.empty()) return f;
for (int i = 0; i < (int)f.size() - 1; i++){
f[i] = f[i + 1] * (T)(i + 1);
}
f.pop_back();
return f;
}
}
#line 3 "/Users/Shared/po167_library/fps/FPS_integral.hpp"
namespace po167{
template <class T>
std::vector<T> FPS_integral(std::vector<T> f){
if (f.empty()) return f;
std::vector<T> num_inv((int)f.size() + 1);
num_inv[0] = 1;
num_inv[1] = 1;
auto m = T::mod();
for (int i = 2; i <= (int)f.size(); i++){
num_inv[i] = (0 - num_inv[m % i]) * (T)(m / i);
}
f.reserve((int)f.size() + 1);
f.push_back(0);
for (int i = (int)f.size() - 1; i > 0; i--){
f[i] = f[i - 1] * num_inv[i];
}
f[0] = 0;
return f;
}
}
#line 3 "/Users/Shared/po167_library/fps/FPS_inv.hpp"
#include <atcoder/convolution>
namespace po167{
// return 1 / f
template <class T>
std::vector<T> FPS_inv(std::vector<T> f, int len = -1){
if (len == -1) len = f.size();
assert(f[0] != 0);
std::vector<T> g = {1 / f[0]};
int s = 1;
while(s < len){
// g = 2g_s - f(g_s)^2 (mod x ^ (2 * s))
// g = g - (fg - 1)g
// (fg - 1) = 0 (mod x ^ (s))
std::vector<T> n_g(s * 2, 0);
std::vector<T> f_s(s * 2, 0);
g.resize(s * 2);
for (int i = 0; i < s * 2; i++){
if (int(f.size()) > i) f_s[i] = f[i];
n_g[i] = g[i];
}
atcoder::internal::butterfly(g);
atcoder::internal::butterfly(f_s);
for (int i = 0; i < s * 2; i++){
f_s[i] *= g[i];
}
atcoder::internal::butterfly_inv(f_s);
T iz = 1 / (T)(s * 2);
for (int i = s; i < s * 2; i++){
f_s[i] *= iz;
}
for (int i = 0; i < s; i++){
f_s[i] = 0;
}
atcoder::internal::butterfly(f_s);
for (int i = 0; i < s * 2; i++){
f_s[i] *= g[i];
}
atcoder::internal::butterfly_inv(f_s);
for (int i = s; i < s * 2; i++){
n_g[i] -= f_s[i] * iz;
}
std::swap(n_g, g);
s *= 2;
}
g.resize(len);
return g;
}
}
#line 6 "/Users/Shared/po167_library/fps/FPS_log.hpp"
namespace po167{
template<class T>
std::vector<T> FPS_log(std::vector<T> f, int len = -1){
if (len == -1) len = f.size();
if (len == 0) return {};
if (len == 1) return {T(0)};
assert(!f.empty() && f[0] == 1);
std::vector<T> res = atcoder::convolution(FPS_differential(f), FPS_inv(f, len));
res.resize(len - 1);
return FPS_integral(res);
}
}
#line 4 "/Users/Shared/po167_library/fps/FPS_Product_Sequence.hpp"
namespace po167{
template<class T>
std::vector<T> FPS_Product_Sequence(std::vector<std::vector<T>> f){
if (f.empty()) return {1};
auto op = [&](auto self,int l, int r) -> std::vector<T> {
if (l + 1 == r) return f[l];
int m = (l + r) / 2;
return atcoder::convolution(self(self, l, m), self(self, m, r));
};
return op(op, 0, f.size());
}
}
#line 3 "main.cpp"
using mint = atcoder::modint998244353;
std::vector<mint> f(std::vector<mint> A, int M){
std::vector<std::vector<mint>> B(A.size());
for (int i = 0; i < (int)(A.size()); i++){
B[i] = {1, - A[i]};
}
auto C = po167::FPS_Product_Sequence(B);
C = po167::FPS_log(C, M + 1);
std::vector<mint> res(M + 1);
res[0] = (int)A.size();
for (int i = 0; i < M; i++){
res[i + 1] = C[i + 1] * -1 * (i + 1);
}
return res;
}
#include <iostream>
int main(){
int N, M;
std::cin >> N >> M;
std::vector<mint> A(N);
for (int i = 0; i < N; i++){
int a;
std::cin >> a;
A[i] = a;
}
auto ans = f(A, M);
for (int i = 1; i <= M; i++) std::cout << ans[i].val() << "\n";
}
potato167