Main topic:
The number of points in the (N,n,n) range is observed from the coordinates (0,0,0), and if more than one point appears on a line, all but the first one is considered obscured.
This topic a little deduction to know that gcd (x, y, Z) = 1 points are observable, if the gcd>1 of the three, then there must be a point (X/GCD (x, Y, z), Y/GCD (x, Y, z), Z/GCD (x, Y, z)) points
So because 0 is unable to calculate the GCD, so first don't consider 0
1. X>0, y>0, z>0 ans =∑x<=n∑y<=n∑z<=n[gcd (x, Y, z) =1]->∑x<=n∑y<=n∑z<=n∑d|gcd (x, Y, z) mu[ D
2. Only one 0 ans = * * (∑X<=N∑Y<=N[GCD (x, y) =1]), * * (∑X<=N∑Y<=N∑D|GCD (x, y) mu[d])
3.3 Numbers two for 0 ans = 3
So just adding the 3 values above is the answer we asked for.
1#include <cstdio>2#include <cstring>3 using namespacestd;4 Const intMAXN =1000000;5 #definell Long Long6 intmu[maxn+5], prime[maxn/Ten];7 BOOLcheck[maxn+5];8 9 voidGETMU (intN)Ten { Onememset (check,0,sizeof(check)); A inttot=0; -check[1] =true, mu[1]=1, mu[2]=-1; - for(intI=2; I<=n; i++){ the if(!check[i]) prime[tot++]=i, mu[i]=-1; -Check[i] =true; - for(intj=0; J<tot; J + +){ - if(i*prime[j]>n) Break; +check[i*prime[j]]=true; - if(I%prime[j] = =0){ +MU[I*PRIME[J]] =0; A Break; at}Else{ -MU[I*PRIME[J]] =-Mu[i]; - } - } - } - } in - intMain () to { + //freopen ("a.in", "R", stdin); - GETMU (MAXN); the intT, N; *scanf"%d", &T); $ while(t--)Panax Notoginseng { -scanf"%d", &n); thell ans =0; + for(intI=1; I<=n; i++){ All tmp1 = (ll) (n/i) * (n/i) * (n/i) *mu[i];//a situation where a 0 doesn't exist in the coordinates. thell tmp2 = (ll)3* (n/i) * (n/i) *mu[i];//there's a zero in the coordinates. +ll Tmp3 = (ll)3* (n/i) *mu[i];//There are two zeros in the coordinates. -Ans + = tmp1+tmp2+Tmp3; $ } $printf"%lld\n", ans); - } - return 0; the}
Spoj-vlattice Visible Lattice Points-mo