//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<cstring>",
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register LL",
            "const int N=103,P=1e9+7;",
            "LL n,K;",
            "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;",
            "}",
            "struct Matrix{",
            "\tLL a[N][N];",
            "\tMatrix(){memset(a,0,sizeof(a));}",
            "\tinline void read(){",
            "\t\tfor(Re i=1;i<=n;++i)",
            "    \t\tfor(Re j=1;j<=n;++j)\t",
            "    \t\t\tin(a[i][j]);",
            "\t}",
            "\tinline void print(){",
            "\t\tfor(Re i=1;i<=n;puts(\"\"),++i)",
            "    \t\tfor(Re j=1;j<=n;++j)\t",
            "    \t\t\tprintf(\"%lld \",a[i][j]);",
            "\t}",
            "\tinline Matrix operator*(const Matrix &O)const{",
            "\t\tMatrix ans;",
            "\t\tfor(Re i=1;i<=n;++i)",
            "\t\t\tfor(Re j=1;j<=n;++j)",
            "\t\t\t\tfor(Re k=1;k<=n;++k)",
            "\t\t\t\t\t(ans.a[i][j]+=a[i][k]*O.a[k][j]%P)%=P;",
            "\t\treturn ans;",
            "\t}",
            "\tinline Matrix operator*=(Matrix &O){return *this=*this*O;}",
            "}A;",
            "inline Matrix mi(Matrix x,Re k){",
            "\tif(!k)return x;--k;",
            "\tMatrix s=x;",
            "\twhile(k){",
            "\t\tif(k&1)s*=x;",
            "\t\tx*=x,k>>=1;",
            "\t}",
            "\treturn s;",
            "}",
            "int main(){",
            "\tin(n),in(K),A.read(),mi(A,K).print();",
            "}",
            ""
        ],
        "description": "插入 矩阵快速幂"
    }
}