std::bitset<1000003> v; int p[78501], mu[1000003];
voidsieve(int N){ int m = 0;
v.set(1), mu[1] = 1; for (int i = 2; i <= N; ++i) { if (!v[i]) p[++m] = i, mu[i] = -1; for (int j = 1; j <= m && i * p[j] <= N; ++j) { v.set(i * p[j]); if (i % p[j] == 0) break; mu[i * p[j]] = -mu[i]; } mu[i] += mu[i - 1]; } }
intmain(){ int A, B, d; longlong ans = 0;
std::cin >> A >> B >> d; A /= d, B /= d; if (A > B) std::swap(A, B);
sieve(A); for (int l = 1, r, a, b; l <= A; l = r + 1) { a = A / l, b = B / l; r = std::min(A / a, B / b); ans += 1ll * a * b * (mu[r] - mu[l - 1]); } std::cout << ans << '\n'; return0; }
std::bitset<10003> v, vm; int MX, base, p[1231], mu[10003], mu_[10003];
inlineintto(int x){ return MX / x; }
voidsieve(int N); // 同 code 1
intgetMu(int N){ if (N <= base) return mu[N]; if (vm[to(N)]) return mu_[to(N)]; int ans = 0; for (int l = 2, r, L; l <= N; l = r + 1) { L = N / l, r = N / L; ans += (r - l + 1) * getMu(L); } vm.set(to(N)); return mu_[to(N)] = 1 - ans; }
intmain(){ int A, B, d; longlong ans = 0;
std::cin >> A >> B >> d; A /= d, B /= d; if (A > B) std::swap(A, B);
MX = A, base = pow(A, 2. / 3); sieve(base); for (int l = 1, r, a, b, gR, gL; l <= A; l = r + 1) { a = A / l, b = B / l; r = std::min(A / a, B / b); vm.reset(), gR = getMu(r); vm.reset(), gL = getMu(l - 1); ans += 1ll * a * b * (gR - gL); } std::cout << ans << '\n'; return0; }