codeforces|【CF 235E】Number Challenge

codeforces|【CF 235E】Number Challenge
文章图片
1?≤?a,?b,?c?≤?2000
codeforces|【CF 235E】Number Challenge
文章图片
codeforces|【CF 235E】Number Challenge
文章图片


【codeforces|【CF 235E】Number Challenge】

#include #include #include #include #include #define Rep(i, x, y) for (int i = x; i <= y; i ++) #define Dwn(i, x, y) for (int i = x; i >= y; i --) #define RepE(i, x) for(int i = pos[x]; i; i = g[i].nex) using namespace std; typedef long long LL; const int N = 2005, M = N * N, mod = 1073741824; int A, B, C, mu[M], pri[M], pz, num[M], ab; LL f[M], ans; bool c[M]; void Pre() { mu[1] = 1; Rep(i, 2, C) { if (!c[i]) pri[++ pz] = i, mu[i] = -1; Rep(j, 1, pz) { int k = pri[j] * i; if (k > ab) break ; c[k] = 1, mu[k] = -mu[i]; if (i % pri[j] == 0) { mu[k] = 0; break ; } } } Rep(e, 1, C) { LL k = 0; Rep(d, 1, C) k += C / (e * d); for (int g = e; g <= ab; g += e) f[g] += mu[e] * k; } Rep(g, 1, ab) f[g] %= mod; } int main() { scanf ("%d%d%d", &A, &B, &C); Rep(i, 1, A) Rep(j, 1, B) num[i * j] ++; ab = A * B; Pre(); // puts("fin"); Rep(g, 1, ab) if (num[g]) { LL k1 = 0; Rep(j, 1, ab / g) (k1 += num[j * g]) %= mod; (ans += f[g] * k1) %= mod; } cout << ((ans + mod) % mod) << endl; return 0; }




    推荐阅读