//Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and 
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
// same ids are connected.
// prefix 的格式要求是 acm-[一级标题编号].[二级标题编号][该代码片段的英文简称]
// description 的格式要求是 "插入 [该代码片段的中文名]"

{
    "拉格朗日插值": {
        "prefix": "acm-7.4x从0到n连续",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=1048576+3,P=998244353,G=3;",
            "int jc[N],inv[N],invjc[N];",
            "inline void in(Re &x){",
            "\tint f=0;x=0;char ch=getchar();",
            "\twhile(ch<'0'||ch>'9')f|=ch=='-',ch=getchar();",
            "\twhile(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "\tx=f?-x:x;",
            "}",
            "inline int mi(Re x,Re k){",
            "\tRe s=1;",
            "\twhile(k){",
            "\t\tif(k&1)s=(LL)s*x%P;",
            "\t\tx=(LL)x*x%P,k>>=1;",
            "\t}",
            "\treturn s;",
            "}",
            "inline int Inv(Re x){return mi(x,P-2);}",
            "int invG,tr[N];",
            "inline void NTT(Re *f,Re n,Re op){",
            "\tfor(Re i=0;i<n;++i)if(i<tr[i])swap(f[i],f[tr[i]]);",
            "\tfor(Re p=2;p<=n;p<<=1){",
            "\t\tRe len=p>>1,w1=mi(op?invG:G,(P-1)/p);",
            "\t\tfor(Re st=0;st<n;st+=p)",
            "\t\t\tfor(Re i=st,base=1;i<=st+len-1;++i){",
            "\t\t\t\tRe tmp=(LL)base*f[len+i]%P;",
            "\t\t\t\tf[len+i]=(f[i]-tmp+P)%P,(f[i]+=tmp)%=P,base=(LL)base*w1%P;",
            "\t\t\t}",
            "\t}",
            "}",
            "inline void times(Re *f,Re n,Re *g,Re m){",
            "\tfor(m+=n,n=1;n<=m;n<<=1);invG=Inv(G);",
            "\tfor(Re i=1;i<n;++i)tr[i]=(tr[i>>1]>>1)|((i&1)?n>>1:0);",
            "\tNTT(f,n,0),NTT(g,n,0);",
            "\tfor(Re i=0;i<n;++i)f[i]=(LL)f[i]*g[i]%P;",
            "\tNTT(f,n,1);Re invn=Inv(n);",
            "\tfor(Re i=0;i<=m;++i)f[i]=(LL)f[i]*invn%P;",
            "}",
            "int n,m,y[N],f[N],g[N],F[N];",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(n),in(m),jc[0]=jc[1]=inv[1]=invjc[0]=invjc[1]=1;",
            "\tfor(Re i=2;i<=n;++i)inv[i]=(LL)inv[P%i]*(P-P/i)%P,jc[i]=(LL)jc[i-1]*i%P,invjc[i]=(LL)invjc[i-1]*inv[i]%P;",
            "\tfor(Re i=0;i<=n;++i)in(y[i]),g[i]=(LL)y[i]*((n-i&1)?P-1:1)%P*invjc[i]%P*invjc[n-i]%P;",
            "\tfor(Re i=0;i<=(n<<1);++i)f[i]=Inv(m-n+i);",
            "\ttimes(f,n<<1,g,n);Re tmp=1;",
            "\tfor(Re i=m-n;i<=m;++i)tmp=(LL)tmp*i%P;",
            "\tfor(Re i=0;i<=n;tmp=(LL)tmp*Inv(m-n+i)%P,++i,tmp=(LL)tmp*(m+i)%P)F[i]=(LL)tmp*f[n+i]%P;",
            "\tfor(Re i=m;i<=m+n;++i)printf(\"%d \",F[i-m]);",
            "}",
            ""
        ],
        "description": "插入 拉格朗日插值"
    }
}