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

{
    "卡特兰数Catalan": {
        "prefix": "acm-7.2质因数分解 取模",
        "body": [
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register LL",
            "const int N=1e6+3;",
            "LL n,P,cnt,pri[N],pan[N<<1];",
            "inline void get_pri(Re N){",
            "    for(Re i=2;i<=N;++i){",
            "        if(!pan[i])pri[++cnt]=i;",
            "        for(Re j=1;j<=cnt&&i*pri[j]<=N;++j)pan[i*pri[j]]=1;",
            "    }",
            "}",
            "inline LL Catalan(Re n){",
            "    Re ans=1;cnt=0;get_pri(n<<1);",
            "    for(Re i=1;i<=cnt;i++){",
            "        Re x=pri[i],t=0;",
            "        while(x<=2*n){t+=2*n/x-n/x-(n+1)/x;x*=pri[i];}",
            "        while(t--)(ans*=pri[i])%=P;",
            "    }",
            "    return ans%P;",
            "}",
            "int main(){",
            "    scanf(\"%lld%lld\",&n,&P);",
            "\tprintf(\"%lld\",Catalan(n));",
            "}",
            ""
        ],
        "description": "插入 卡特兰数Catalan"
    }
}