多项式求逆
解决问题类型
\[f(x)\times g(x)\equiv 1\pmod {x^n}
\]
已知 \(f(x)\),求 \(g(x)\)。
推导
\[f(x)\times g_0(x)\equiv1\pmod {x^{\lceil \frac{n}{2} \rceil}}
\]
\[f^2(x)\times {g_0}^2(x)-2f(x)\times g_0(x)+1\equiv 0\pmod {x^n}
\]
\[1\equiv 2f(x)\times g_0(x)-f^2(x)\times {g_0}^2(x)\pmod {x^n}
\]
\[g(x)\equiv 2\times g_0(x)-f(x)\times {g_0}^2(x)\pmod {x^n}
\]
模板代码
应用
$$\texttt{Dirty Deeds Done Dirt Cheap}$$