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

{
    "Polya定理": {
        "prefix": "acm-7.2mi",
        "body": [
            "#include<algorithm>",
            "#include<cstring>",
            "#include<cstdio>",
            "#define LL long long",
            "#define Re register int",
            "using namespace std;",
            "const int N=1e6+3,P=1e9+7;",
            "int n,T,pri[N/3];bool pan[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 int mi(Re x,Re k){",
            "\tRe s=1;",
            "\twhile(k){",
            "\t\tif(k&1)s=(LL)s*x%P;",
            "\t\tx=(LL)x*x%P,k>>=1;",
            "\t}",
            "\treturn s;",
            "}",
            "inline int inv(Re x){return mi(x,P-2);}",
            "inline int phi(Re x){",
            "\tRe ans=x;",
            "\tfor(Re i=2;i*i<=x;i++)",
            "\t\tif(x%i==0){",
            "\t\t\tans/=i,ans*=i-1;",
            "\t\t\twhile(x%i==0)x/=i;",
            "\t\t}",
            "\tif(x>1)ans/=x,ans*=x-1;",
            "\treturn ans;",
            "}",
            "int main(){",
            "//\tfreopen(\"123.txt\",\"r\",stdin);",
            "\tin(T);",
            "\twhile(T--){",
            "\t\tin(n);Re ans=0;",
            "\t\tfor(Re i=1;i*i<=n;++i)",
            "\t\t\tif(n%i==0){",
            "\t\t\t\t(ans+=(LL)mi(n,i-1)*phi(n/i)%P)%=P;",
            "\t\t\t\tif(i!=n/i)(ans+=(LL)mi(n,n/i-1)*phi(i)%P)%=P;",
            "\t\t\t}",
            "\t\tprintf(\"%d\\n\",ans);",
            "\t}",
            "}",
            ""
        ],
        "description": "插入 Polya定理"
    }
}