问题
给定一个多项式(F(x)) ,请求出一个多项式(G(x)),满足(F(x) imes G(x) equiv 1(mathrm{mod:}x^n))
推导
假设我们已经求得了(G_0(x))满足(F(x) imes G_0(x) equiv 1(mathrm{mod:}x^frac{n}{2})),现在求(F(x) imes G(x) equiv 1(mathrm{mod:}x^n))。
[egin{aligned}
F(x) imes G_0(x) &equiv 1(mathrm{mod:}x^frac{n}{2})\
F(x) imes G_0(x)-1 &equiv 0(mathrm{mod:}x^frac{n}{2})\
(F(x) imes G_0(x)-1)^2 &equiv 0(mathrm{mod:}x^n)\
(F(x) imes G_0(x))^2+1-2 imes F(x) imes G_0(x) &equiv 0(mathrm{mod:}x^n)\
F(x)^2 imes G_0(x)^2+1-2 imes F(x) imes G_0(x) &equiv 0(mathrm{mod:}x^n)\
F(x)^2 imes G_0(x)^2-2 imes F(x) imes G_0(x) &equiv -1(mathrm{mod:}x^n)\
2 imes F(x) imes G_0(x)-F(x)^2 imes G_0(x)^2 &equiv 1(mathrm{mod:}x^n)\
F(x) imes(2 imes G_0(x)-F(x) imes G_0(x)^2) &equiv 1(mathrm{mod:}x^n)
end{aligned}]
所以我们在已知(G_0(x))的前提下,只要求一下(2 imes G_0(x)-F(x) imes G_0(x)^2))就可以了。
时间复杂度
(O(nlog n))