1257: [CQOI2007]余数之和 Time Limit: 5 Sec Memory Limit: 128 MBSubmit: 6117 Solved: 2949[Submit][Status][Discuss] Description 给出正整数n和k,计算j(n, k)=k mod 1 + k mod 2 + k mod 3 + … + k mod n的值 其中k mod i表示k除以i的余数. 例如j(5, 3)=3 mod 1 + 3 mod 2 + 3 mod 3 + 3 m
求∑1<=i<=n∑1<=j<=ngcd(i,j) % P P = 10^9 + 7 2 <= n <= 10^10 这道题,明显就是杜教筛 推一下公式: 利用∑d|nphi(d) = n ans = ∑1<=i<=n∑1<=j<=n∑d|(i,j)phi(d) = ∑1<=d<=n∑1<=i<=n∑1<=j<=n[d|(i,j)]phi(d) = ∑1<=d<=nphi(d)∑1<=i<