//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 Star not a Tree？)": {
        "prefix": "acm-1.5坐标系随机移动",
        "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=1e6+3;",
            "int n,HYJ,X[N],Y[N];",
            "inline void in(Re &x){",
            "    int f=0;x=0;char c=getchar();",
            "    while(c<'0'||c>'9')f|=c=='-',c=getchar();",
            "    while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();",
            "    x=f?-x:x;",
            "}",
            "inline LD calc(LD x,LD y){",
            "\tLD tmp=0;",
            "\tfor(Re i=1;i<=n;++i)tmp+=sqrt((x-X[i])*(x-X[i])+(y-Y[i])*(y-Y[i]));",
            "\treturn tmp;",
            "}",
            "inline void Srand(Re seed){",
            "\tsrand(seed);Re a=rand()%10+1;",
            "\twhile(a--)srand(rand());",
            "}",
            "LD ans,ansx,ansy;",
            "const LD deltaT=0.99,maxT=4995,minT=1e-12;",
            "inline void fire(){",
            "\tLD x=ansx,y=ansy,nowT=maxT;",
            "\twhile(nowT>minT){",
            "\t\tLD nx=x+((rand()<<1)-RAND_MAX)*nowT;",
            "\t\tLD ny=y+((rand()<<1)-RAND_MAX)*nowT;",
            "\t\tLD nans=calc(nx,ny),deltaE=nans-ans;",
            "\t\tif(deltaE<0)ans=nans,ansx=x=nx,ansy=y=ny;",
            "\t\telse if(exp(-deltaE/nowT)>(LD)rand()/RAND_MAX)x=nx,y=ny;",
            "\t\tnowT*=deltaT;",
            "\t}",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(HYJ),Srand(20030825);",
            "\twhile(HYJ--){",
            "\t\tin(n);",
            "\t\tfor(Re i=1;i<=n;++i)in(X[i]),in(Y[i]);",
            "\t\tans=calc(X[1],Y[1]),ansx=X[1],ansy=Y[1];",
            "\t\tfire(),fire(),fire(),fire(),fire();",
            "\t\tprintf(\"%.lf\\n\",ans);",
            "\t\tif(HYJ)puts(\"\");",
            "\t}",
            "}",
            ""
        ],
        "description": "插入 模拟退火  (A Star not a Tree？)"
    }
}