思路
按如下式子计算即可
\[ B(x)=\frac{A(x)+B'^2(x)}{2B'(x)} \]
代码
// luogu-judger-enable-o2#include#include #include #define int long longusing namespace std;const int MAXN = 300000;const int G = 3;const int invG = 332748118;const int MOD = 998244353;int n;struct Poly{ int t;//次数界 int data[MAXN]; Poly(){} Poly(int x,int val[]){ for(int i=0;i<=x;i++) data[i]=val[i]; }};int pow(int a,int b){ int ans=1; while(b){ if(b&1) ans=(1LL*ans*a)%MOD; a=(1LL*a*a)%MOD; b>>=1; } return ans;}void rever(Poly &a){ for(int i=0,j=a.t;i >j)&1) t|=(1<<(lim-j-1)); if(i >1,len); static Poly tmp1,tmp2,tmp; while((dep<<1)>len) len<<=1; for(int i=0;i >1); // printf("dep=%lld\n",dep); while((dep<<1)>(midlen)) midlen<<=1; static Poly tmp1,tmp2,tmp3; tmp1=b;tmp3=b; save(tmp1,dep-1); save(tmp3,dep-1); save(tmp2,-1); int midlent=1; for(int i=0;i