Test instructions: The two-point (x, Y, z) connection does not go through a few other points
Solution: That is, for gcd (x, Y, Z) 1 points have several
Jie Yi: Because x, Y, Z are all within the 1~n, you can use Euler functions to solve
Solution Two: The inverse of the mo-Black
Set F[n] is the number of gcd (x, Y, z) =n
Set F[b] to b| The number of GCD (x, Y, z) is obvious f[b]= (n/i) * (n/i) * (n/i)
So F[n]=sigema (B|n,f[b]);
F[n]=sigema (N|b,mu[n],f[n])
#include <stdio.h> #include <string.h>const int maxn=1000005;int prime[maxn];int num[maxn];int MU[MAXN]; void Mobius () {memset (num,0,sizeof (num)); Mu[1]=1; int all=0; for (int i=2;i<maxn;i++) {if (!num[i]) {prime[all++]=i; Mu[i]=-1; } for (int j=0;j<all&&i*prime[j]<maxn;j++) {num[i*prime[j]]=1; if (I%prime[j]) mu[i*prime[j]]=-mu[i]; else {mu[i*prime[j]]=0; Break }}} return;} int main () {int t; int n; a long long sum; Mobius (); while (scanf ("%d", &t)!=-1) {while (t--) {sum=3; X, y, Z axis scanf ("%d", &n); for (int i=1;i<=n;i++) {sum+= (Long Long) mu[i]* (n/i) * (n/i) * ((n/i) +3); The point on the face, so +3} printf ("%lld\n", sum); }} RETUrn 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Spoj vlattice Visible Lattice Points first entry Möbius