题解 SGU294 He's Circles
失踪人口回归
根据\(Polya\)定理$$ans=\frac 1n \sum\limits_{i=1}n2$$
考虑枚举\(gcd\),原式变成$$\frac 1n \sum\limits_{d|n}2d\sum\limits_{i=1}n\big[gcd(i,n)=d\big]$$
用\(id\)替换\(i\) $$\frac 1n \sum\limits_{d|n}2d\sum\limits_{i=1}\big[gcd(i,\frac nd)=1\big]$$
\(\sum\limits_{i=1}^{\frac nd}\big[gcd(i,\frac nd)=1\big]\)这个东西显然是\(\varphi(\frac nd)\),所以答案即为$$\frac 1n \sum\limits_{d|n}2^d\varphi(\frac nd)$$
这题比较恶心的地方就是高精