//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 的格式要求是 "插入 [该代码片段的中文名]"

{
    "A×B Problem": {
        "prefix": "acm-7.4FFT",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#include<cmath>",
            "#define LD double",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=2097152+5;",
            "const LD Pi=acos(-1);",
            "int n,m,tr[N],Ans[N];char s1[N>>1],s2[N>>1];",
            "inline void in(Re &x){",
            "\tRe fu=0;x=0;char ch=getchar();",
            "\twhile(ch<'0'||ch>'9')fu|=ch=='-',ch=getchar();",
            "\twhile(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();",
            "\tx=fu?-x:x;",
            "}",
            "struct CP{",
            "\tLD x,y;",
            "\tCP(LD X=0,LD Y=0){x=X,y=Y;}",
            "\tinline CP operator+(const CP &O)const{return CP(x+O.x,y+O.y);}",
            "\tinline CP operator-(const CP &O)const{return CP(x-O.x,y-O.y);}",
            "\tinline CP operator*(const CP &O)const{return CP(x*O.x-y*O.y,x*O.y+y*O.x);}",
            "\tinline CP operator*=(const CP &O){return *this=*this*O;}",
            "}f[N],g[N];",
            "inline void FFT(CP *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;",
            "\t\tCP w1(cos(2*Pi/p),sin(2*Pi/p));",
            "\t\tif(op)w1.y*=-1;",
            "\t\tfor(Re st=0;st<n;st+=p){",
            "\t\t\tCP base(1,0);",
            "\t\t\tfor(Re i=st;i<=st+len-1;++i){",
            "\t\t\t\tCP tmp=f[len+i]*base;",
            "\t\t\t\tf[len+i]=f[i]-tmp,f[i]=f[i]+tmp,base*=w1;",
            "\t\t\t}",
            "\t\t}",
            "\t}",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tscanf(\"%s%s\",s1,s2),n=strlen(s1),m=strlen(s2);",
            "\tfor(Re i=0;i<n;++i)f[i].x=s1[n-i-1]-'0';",
            "\tfor(Re i=0;i<m;++i)g[i].x=s2[m-i-1]-'0';",
            "\tfor(m+=n,n=1;n<=m;n<<=1);",
            "\tfor(Re i=1;i<n;++i)tr[i]=(tr[i>>1]>>1)|((i&1)?n>>1:0);",
            "\tFFT(f,n,0),FFT(g,n,0);",
            "\tfor(Re i=0;i<n;++i)f[i]*=g[i];",
            "\tFFT(f,n,1);",
            "\tfor(Re i=0;i<=m;++i){",
            "\t\tAns[i]+=(int)(f[i].x/n+0.5);",
            "\t\tif(Ans[i]>9)Ans[i+1]+=Ans[i]/10,Ans[i]%=10,m+=(i==m);",
            "\t}",
            "\twhile(!Ans[m]&&m>=1)--m;",
            "\tfor(Re i=m;i>=0;--i)printf(\"%d\",Ans[i]);",
            "}",
            ""
        ],
        "description": "插入 A×B Problem"
    }
}