#include<iostream> #include<cstdio> #define maxn 50010 #define ll long long usingnamespacestd;
int n, m, k;
int pri[maxn], cnt, mu[maxn]; bool isp[maxn]; voidinit_isp(int n){ mu[1] = 1; for (int i = 2; i <= n; ++i) { if (!isp[i]) pri[++cnt] = i, mu[i] = -1; for (int j = 1; j <= cnt && i * pri[j] <= n; ++j) { isp[i * pri[j]] = 1; if (i % pri[j] == 0) break; mu[i * pri[j]] = -mu[i]; } } for (int i = 1; i <= n; ++i) mu[i] += mu[i - 1]; }
voidwork(){ cin >> n >> m >> k; n /= k; m /= k; if (n > m) swap(n, m); ll ans = 0; for (ll l = 1, r; l <= n; l = r + 1) { r = min(n / (n / l), m / (m / l)); ans += (mu[r] - mu[l - 1]) * (n / l) * (m / l); } cout << ans << "\n"; }