题意:
已知 n < = 1 e 6 n<=1e6 n<=1e6,求:
f ( n ) = ∑ i = 1 n ∑ j = 1 i ⌈ i j ⌉ [ g c d ( i , j ) = = 1 ] f(n) = \sum_{i=1}^n\sum_{j=1}^i \lceil\frac{i}{j}\rceil[gcd(i,j) == 1] f(n)=i=1∑nj=1∑i⌈ji⌉[gcd(i,j)==1]
思路:
首先套上莫比乌斯反演的经典转化:
∑ d ∣ n μ ( d ) = [ n = = 1 ] \sum_{d|n}\mu(d) = [n == 1] d∣n∑μ(d)=[n==1]
得:
f ( n ) = ∑ i = 1 n ∑ j = 1 i ⌈ i j ⌉ ∑ d ∣ g c d ( i , j ) μ ( d ) f(n) = \sum_{i=1}^n\sum_{j=1}^i \lceil\frac{i}{j}\rceil \sum_{d|gcd(i,j)}\mu(d) f(n)=i=1∑nj=1∑i⌈ji</