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