title | documentation_of |
---|---|
線形漸化式に関する高速計算(Bostan-Mori algorithm) |
./coeff_of_rational_function.hpp |
long long N;
vector<mint> P, Q;
mint nth_coeff = coefficient_of_rational_function(N, P, Q);
vector<mint> init = {1, 9, 1, 2}, recurrence = {1, -4, -1, 0, -1};
mint x = find_kth_term(init, recurrence, 12345678910111213);
実装上は,$A(x) = \sum_{i=0}^{K-1} a_i x^i$ と漸化式である coefficient_of_rational_function()
関数が使用可能な形式に帰着させている.
- [1] A. Bostan and R. Mori, “A simple and fast algorithm for computing the N-th term of a linearly recurrent sequence,” SIAM SOSA, pp.118–132, Jan. 11–12 2021.
- 線形漸化的数列のN項目の計算 - Qiita