E. Number Challenge

推式子

∑ i = 1 a ∑ j = 1 b ∑ k = 1 c σ ( i j k ) = ∑ i = 1 a ∑ j = 1 b ∑ k = 1 c ∑ x ∣ i ∑ y ∣ j ∑ z ∣ k ( g c d ( x , y ) = 1 ) ( g c d ( x , z ) = 1 ) ( g c d ( y , z ) = 1 ) = ∑ x = 1 a ∑ y = 1 b ∑ z = 1 c ⌊ a x ⌋ ⌊ b y ⌋ ⌊ c z ⌋ ( g c d ( x , y ) = 1 ) ( g c d ( x , z ) = 1 ) ( g c d ( y , z ) = 1 ) = ∑ d = 1 a μ ( d ) ∑ x = 1 ⌊ a d ⌋ ⌊ a d x ⌋ ∑ y = 1 ⌊ b d ⌋ ⌊ b d y ⌋ ∑ z = 1 c ⌊ c d ⌋ ( g c d ( x , z ) = 1 ) ( g c d ( y , z ) = 1 ) = ∑ d = 1 a μ ( d ) ∑ z = 1 c ⌊ c d ⌋ ∑ x = 1 ⌊ a d ⌋ ⌊ a d x ⌋ ( g c d ( x , z ) = = 1 ) ∑ y = 1 ⌊ b d ⌋ ⌊ b d x ⌋ ( g c d ( y , z ) = = 1 ) \sum_{i = 1} ^{a} \sum_{j = 1} ^{b} \sum_{k = 1} ^{c} \sigma(ijk)\\ = \sum_{i = 1} ^{a} \sum_{j = 1} ^{b} \sum_{k = 1} ^{c} \sum_{x \mid i} \sum_{y \mid j} \sum_{z \mid k}(gcd(x,y) = 1)(gcd(x, z) = 1)(gcd(y, z) = 1)\\ = \sum_{x = 1} ^{a} \sum_{y = 1} ^{b} \sum_{z = 1} ^{c} \lfloor\frac{a}{x}\rfloor \lfloor \frac{b}{y}\rfloor \lfloor \frac{c}{z}\rfloor(gcd(x, y) = 1)(gcd(x, z) = 1)(gcd(y, z) = 1)\\ = \sum_{d = 1} ^{a} \mu(d) \sum_{x = 1} ^{\lfloor \frac{a}{d} \rfloor} \lfloor\frac{a}{dx}\rfloor \sum_{y = 1} ^{\lfloor \frac{b}{d}\rfloor} \lfloor \frac{b}{dy} \rfloor \sum_{z = 1} ^{c} \lfloor\frac{c}{d} \rfloor (gcd(x, z) = 1)(gcd(y, z) = 1)\\ = \sum_{d = 1} ^{a} \mu(d) \sum_{z = 1} ^{c} \lfloor \frac{c}{d} \rfloor \sum_{x = 1} ^{\lfloor \frac{a}{d}\rfloor} \lfloor \frac{a}{dx} \rfloor (gcd(x, z) == 1) \sum_{y = 1} ^{\lfloor \frac{b}{d}\rfloor}\lfloor\frac{b}{dx}\rfloor(gcd(y, z) == 1)\\ i=1aj=1bk=1c​σ(ijk)=i=1aj=1bk=1cx∣iy∣jz∣k​(gcd(x,y)=1)(gcd(x,z)=1)(gcd(y,z)=1)=x=1ay=1bz=1c​⌊xa​⌋⌊yb​⌋⌊zc​⌋(gcd(x,y)=1)(gcd(x,z)=1)(gcd(y,z)=1)=d=1a​μ(d)x=1da​⌋​⌊dxa​⌋y=1db​⌋​⌊dyb​⌋z=1c​⌊dc​⌋(gcd(x,z)=1)(gcd(y,z)=1)=d=1a​μ(d)z=1c​⌊dc​⌋x=1da​⌋​⌊dxa​⌋(gcd(x,z)==1)y=1db​⌋​⌊dxb​⌋(gcd(y,z)==1)

然后就是的 n 2 log ⁡ n n ^ 2 \log n n2logn乱搞了。

代码

/*
  Author : lifehappy
*/
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define endl '\n'
#define mid (l + r >> 1)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define ls rt << 1
#define rs rt << 1 | 1

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

const double pi = acos(-1.0);
const double eps = 1e-7;
const int inf = 0x3f3f3f3f;

inline ll read() {
    ll f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-')    f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    return f * x;
}

const int N = 2e3 + 10, mod = 1073741824;

int g[N][N], prime[N], cnt;

bool st[N];

ll mu[N], a, b, c;

void init() {
    mu[1] = 1;
    for(int i = 2; i < N; i++) {
        if(!st[i]) {
            prime[cnt++] = i;
            mu[i] = -1;
        }
        for(int j = 0; j < cnt && i * prime[j] < N; j++) {
            st[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
            mu[i * prime[j]] = -mu[i];
        }
    }
}

int gcd(int a, int b) {
    if(!b) return a;
    if(g[a][b]) return g[a][b];
    return g[a][b] = gcd(b, a % b);
}

void get_gcd() {
    for(int i = 1; i <= c; i++) {
        for(int j = 1; j <= c; j++) {
            g[i][j] = gcd(i, j);
        }
    }
}

void Sort(ll & a, ll & b, ll & c) {
    ll A = a, B = b, C = c;
    a = min({A, B, C});
    c = max({A, B, C});
    b = A + B + C - a - c;
}

ll f(ll n, ll m) {
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        if(g[i][m] == 1) {
            ans += n / i;
        }
    }
    ans = (ans + mod) % mod;
    return ans;
}

int main() {
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    a = read(), b = read(), c = read();
    Sort(a, b, c);
    init();
    get_gcd();
    ll ans = 0;
    for(int i = 1; i <= a; i++) {
        for(int j = 1; j <= b; j++) {
            if(g[i][j] == 1) {
                ans = (ans + mu[j] * (a / i) % mod * f(b / j, i) % mod * f(c / j, i) % mod + mod) % mod;
            }
        }
    }
    cout << ans << endl;
	return 0;
}