cp-library

競技プログラミング用 C++ ライブラリ

View the Project on GitHub qandori/cp-library

:heavy_check_mark: FPS の合成逆元の内部処理(軽量版)

components/fps_composition_light.hpp · GitHub で見る

64 KiBサイト · 軽量実装

軽量 FPS の合成、power projection、合成逆元で共有する実装です。通常は各公開ヘッダーを include してください。

合成・射影の汎用実装へ軽量 FPS の型を渡します。二変数 Bostan–Mori の各段を通常の一次元畳み込みへ埋め込みます。分母の積は偶数次・奇数次に分解して変換長を抑え、合成は射影の転置として計算します。必要な畳み込みと級数演算はすべて軽量 FPS に委譲し、高速実装の FPS や専用 NTT は読み込みません。

対象の係数数を \(n\) として、時間は \(O(n\log^2 n)\)、保持する各段の分母を含む追加空間は \(O(n\log n)\) です。

依存ライブラリ

検証コード

コード

#ifndef CP_COMPONENTS_FPS_COMPOSITION_LIGHT_HPP
#define CP_COMPONENTS_FPS_COMPOSITION_LIGHT_HPP

#include "../fps/fps_light.hpp"
#include "fps_composition_generic.hpp"

namespace light_fps_algorithms {
template<class T>
LightFormalPowerSeries<T> compose(const LightFormalPowerSeries<T> &outer, const LightFormalPowerSeries<T> &inner, int deg = -1) {
	assert(deg <= (1 << 21) && (deg >= 0 || outer.size() <= (std::size_t(1) << 21)));
	return fps_detail::composition_fallback::compose(outer, inner, deg);
}

template<class T>
LightFormalPowerSeries<T> power_projection(const LightFormalPowerSeries<T> &f, const LightFormalPowerSeries<T> &weights, int deg = -1) {
	return fps_detail::composition_fallback::power_projection(f, weights, deg);
}

template<class T>
LightFormalPowerSeries<T> power_projection(const LightFormalPowerSeries<T> &f, int n, int deg = -1) {
	return fps_detail::composition_fallback::power_projection(f, n, deg);
}

template<class T>
LightFormalPowerSeries<T> compositional_inverse(const LightFormalPowerSeries<T> &f, int deg = -1) {
	return fps_detail::composition_fallback::compositional_inverse(f, deg);
}
}

#endif
Back to top page