题解 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)$$

这题比较恶心的地方就是高精

代码

posted @ 2019-09-04 18:01  Ηydra  阅读(261)  评论(0编辑  收藏  举报