//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.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=103;",
            "int n;LD eps=1e-8,a[N][N];",
            "inline int dcmp(Re a){return a<-eps?-1:(a>eps?1:0);}",
            "inline LD Abs(LD a){return dcmp(a)*a;}",
            "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;",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(n);",
            "\tfor(Re i=1;i<=n;++i)\t",
            "\t\tfor(Re j=1;j<=n+1;++j)",
            "\t\t\tscanf(\"%lf\",&a[i][j]);",
            "\tfor(Re j=1;j<=n;++j){",
            "\t\tRe w=j;",
            "\t\tfor(Re i=j+1;i<=n;++i)",
            "\t\t\tif(dcmp(Abs(a[i][j])-Abs(a[w][j]))>0)w=i;",
            "\t\tfor(Re k=1;k<=n+1;++k)swap(a[j][k],a[w][k]);",
            "\t\tif(!dcmp(a[j][j]))return !puts(\"No Solution\");",
            "\t\tfor(Re i=1;i<=n;++i)",
            "\t\t\tif(i!=j){",
            "\t\t\t\tLD tmp=a[i][j]/a[j][j];",
            "\t\t\t\tfor(Re k=j;k<=n+1;++k)a[i][k]-=a[j][k]*tmp;",
            "\t\t\t}",
            "\t}",
            "\tfor(Re i=1;i<=n;++i)printf(\"%.2lf\\n\",a[i][n+1]/a[i][i]);",
            "}",
            ""
        ],
        "description": "插入 高斯消元"
    }
}