Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A point X is visible from point Y iff no other lattice point lies on the segment joining X and Y.
Input :
The first line contains the number of test cases T. The next T lines contain an interger N
Output :
Output T lines, one corresponding to each test case.
intmain(){ #ifdef LOCAL freopen("in.txt", "r", stdin); #endif #ifndef LOCAL std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); #endif std::vector<int> prime, vis(1e6 + 10), mu(1e6 + 10); mu[1] = 1; for (int i = 2; i <= 1e6; ++i) { if (!vis[i]) { mu[i] = -1; prime.push_back(i); } for (int j = 0; j < prime.size() && i * prime[j] <= 1e6; ++j) { vis[i * prime[j]] = 1; if (i % prime[j] == 0) { mu[i * prime[j]] = 0; break; } else mu[i * prime[j]] = mu[i] * -1; } }
int t; std::cin >> t; while (t--) { int n; std::cin >> n; ll ans = 3; for (int d = 1; d <= n; ++d) { ll k = n / d; ans += mu[d] * (k * k * (k + 3)); } std::cout << ans << '\n'; } return0; }