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

{
    "三点坐标解圆方程  (Circle Through Three Points)": {
        "prefix": "acm-8.3解方程",
        "body": [
            "#include<cstdio>",
            "#include<cmath>",
            "#define LD double",
            "#define LL long long",
            "#define Re register int",
            "#define S(a) ((a)*(a))",
            "using namespace std;",
            "struct Point{LD x,y;Point(LD X=0,LD Y=0){x=X,y=Y;}};",
            "struct Circle{Point O;LD r;Circle(Point P,LD R=0){O=P,r=R;}};",
            "inline Circle getcircle(Point A,Point B,Point C){",
            "\tLD x1=A.x,y1=A.y,x2=B.x,y2=B.y,x3=C.x,y3=C.y;",
            "\tLD D=((S(x2)+S(y2)-S(x3)-S(y3))*(y1-y2)-(S(x1)+S(y1)-S(x2)-S(y2))*(y2-y3))/((x1-x2)*(y2-y3)-(x2-x3)*(y1-y2));",
            "\tLD E=(S(x1)+S(y1)-S(x2)-S(y2)+D*(x1-x2))/(y2-y1);",
            "\tLD F=-(S(x1)+S(y1)+D*x1+E*y1);",
            "//\tprintf(\"(%.3lf,%.3lf), D=%.3lf E=%.3lf F=%.3lf\\n\",D/2.0,E/2.0,D,E,F);",
            "\treturn Circle(Point(-D/2.0,-E/2.0),sqrt((S(D)+S(E)-4.0*F)/4.0));",
            "}",
            "#define abs(x) (x<0?-x:x)",
            "#define sakura(x) (x<0?'-':'+')",
            "inline void print(Point O,LD r){",
            "\tLD a=-O.x,b=-O.y,c=r,d=-2.0*O.x,e=-2.0*O.y,f=S(O.x)+S(O.y)-S(r);",
            "\tif(a!=0)printf(\"(x %c %.3lf)^2 \",sakura(a),abs(a));",
            "    else printf(\"x^2 \");",
            "    if(b!=0)printf(\"+ (y %c %.3lf)^2 \",sakura(b),abs(b));",
            "    else printf(\"+ y^2 \");",
            "    printf(\"= %.3lf^2\\n\",c);",
            "    printf(\"x^2 + y^2\");",
            "    if(d!=0)printf(\" %c %.3lf%c\",sakura(d),abs(d),'x');",
            "    if(e!=0)printf(\" %c %.3lf%c\",sakura(e),abs(e),'y');",
            "    if(f!=0)printf(\" %c %.3lf%c\",sakura(f),abs(f),' ');",
            "    printf(\"= 0\\n\\n\");",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tLD a,b,c,d,e,f;",
            "\twhile(scanf(\"%lf%lf%lf%lf%lf%lf\",&a,&b,&c,&d,&e,&f)!=EOF){",
            "\t\tCircle C=getcircle(Point(a,b),Point(c,d),Point(e,f));print(C.O,C.r);",
            "\t}",
            "}",
            ""
        ],
        "description": "插入 三点坐标解圆方程  (Circle Through Three Points)"
    }
}