Luogu P4238 多项式乘法逆 题解

\(\text{cnblogs}\)

\(\text{Luogu Blogs}\)

\(\texttt{Description}\)

\(\operatorname{deg}=n\) 的多项式 \(f\),求多项式 \(g\),满足

\[f*g\equiv 1 \pmod {x^n} \]

系数对 \(998244353\) 取模。

\(\texttt{restrictions:}1\le n\le10^5\)

\(\texttt{Solution}\)

假设 \(\operatorname{deg}=1\),则可以通过快速幂直接求出来,所以考虑递归。

假设我们已经求出 \(h*f \equiv 1 \pmod {x^n}\),考虑如何转移到 \(x^{2n}\)

显然有

\[f*g\equiv 1\pmod {x^n} \]

于是有

\[f*(g-h)\equiv 0 \pmod {x^n} \]

\[g-h \equiv 0 \pmod {x^n} \]

\[(g-h)^2 \equiv 0 \pmod {x^{2n}} \]

\[g^2-2gh+h^2\equiv 0 \pmod {x^{2n}} \]

同乘 \(f\),有。

\[g-2h+fh^2\equiv 0\pmod {x^{2n}} \]

\[g\equiv h(2+fh)\pmod {x^{2n}} \]

即可求解。

\(\texttt{Code}\)

inline friend Poly Inv(Poly a) {
      if (a.size() == 1) {
        Poly tmp(1) ;
        return tmp[0] = ksm(a[0]),tmp ;
      }
      const int len = a.size() ;
      Poly ta = a; ta.resize((len + 1) >> 1) ;
      Poly tb = Inv(ta) ;
      Getrev(len << 1),a.resize(lim),tb.resize(lim),a.ntt(lim,1),tb.ntt(lim,1) ;
      for (int i = 0; i < lim; ++i) tb[i] = 1ll * tb[i] * (mod + 2 - 1ll * a[i] * tb[i] % mod) % mod ;
      return tb.ntt(lim,-1),tb.resize(len),tb ;
    }
posted @ 2021-07-25 18:10  feicheng  阅读(59)  评论(0编辑  收藏  举报