Meaning of the questions:
There is a \ (n * n * n \ ) three-dimensional Cartesian coordinate space, ask from \ ((0,0,0) \) see if I can see a few points.
Ideas:
Press examine questions intended to ask the subject will find \ (\ sum_ {i = 0 } ^ n \ sum_ {j = 0} ^ n \ sum_ {k = 0} ^ ngcd (i, j, k) == 1 \) , then we define \ (f (n) \) of \ (gcd (i, j, k) == n \) logarithm, \ (F. (n-) \) of \ (gcd (i, j, k) \) is \ \) (n- logarithmic multiple, apparently \ (F (n) \) is easier to find, the available \ (f (1) = \ sum_ {1 | d} \ mu ( \ FRAC {} {D}. 1) F. (D) \) .
Code:
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<ctime>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1000000 + 5;
const int INF = 0x3f3f3f3f;
const ull seed = 131;
const ll MOD = 1e9;
using namespace std;
int mu[maxn], vis[maxn];
int prime[maxn], cnt;
void getmu(int n){
memset(vis, 0, sizeof(vis));
memset(mu, 0, sizeof(mu));
cnt = 0;
mu[1] = 1;
for(int i = 2; i <= n; i++) {
if(!vis[i]){
prime[cnt++] = i;
mu[i] = -1;
}
for(int j = 0; j < cnt && prime[j] * i <= n; j++){
vis[prime[j] * i] = 1;
if(i % prime[j] == 0) break;
mu[i * prime[j]] = -mu[i];
}
}
}
ll get(int n){
return 1LL * n * n * n + 3LL * n * n + 3LL * n;
}
int main(){
int n, T;
getmu(1000000);
scanf("%d", &T);
while(T--){
scanf("%d", &n);
ll ans = 0;
for(int i = 1; i <= n; i++){
ans += 1LL * mu[i] * get(n / i);
}
printf("%lld\n", ans);
}
return 0;
}