# [BZOJ2301][HAOI2011]Problem b（莫比乌斯反演）

$\sum _{i=1}^{b}\sum _{j=1}^{d}\left[gcd\left(i,j\right)=k\right]$

$\sum _{i=1}^{a-1}\sum _{j=1}^{d}\left[gcd\left(i,j\right)=k\right]$

$\sum _{i=1}^{b}\sum _{j=1}^{c-1}\left[gcd\left(i,j\right)=k\right]$

$\sum _{i=1}^{a-1}\sum _{j=1}^{c-1}\left[gcd\left(i,j\right)=k\right]$

#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int res = 0; bool bo = 0; char c;
while (((c = getchar()) < '0' || c > '9') && c != '-');
if (c == '-') bo = 1; else res = c - 48;
while ((c = getchar()) >= '0' && c <= '9')
res = (res << 3) + (res << 1) + (c - 48);
return bo ? ~res + 1 : res;
}
typedef long long ll;
const int N = 5e4;
int pri[N + 5], miu[N + 5], sum[N + 5], cnt;
bool is[N + 5];
void sieve() {
int i, j; miu[1] = 1; is[0] = is[1] = 1;
for (i = 2; i <= N; i++) {
if (!is[i]) pri[++cnt] = i, miu[i] = -1;
for (j = 1; j <= cnt; j++) {
if (1ll * i * pri[j] > N) break;
is[i * pri[j]] = 1;
if (i % pri[j] == 0) break;
else miu[i * pri[j]] = -miu[i];
}
}
for (i = 1; i <= N; i++) sum[i] = sum[i - 1] + miu[i];
}
ll solve(int n, int m) {
if (!n || !m) return 0ll;
int i, nxt; ll ans = 0;
for (i = 1; i <= min(n, m);) {
nxt = min(n / (n / i), m / (m / i));
ans += 1ll * (sum[nxt] - sum[i - 1]) * (n / i) * (m / i);
i = nxt + 1;
}
return ans;
}
int main() {
int T = read(), a, b, c, d, k; sieve();
while (T--) {
}