#include<iostream> #include<cstring> #include<vector> #include<algorithm> #define maxn 50010 #define maxm 200010 #define ll long long #define lowbit(i) ((i) & (-i)) usingnamespacestd;
int pri[maxm], mu[maxm], cnt; bool isp[maxm]; vector<int> d[maxm]; 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) for (int j = i; j <= n; j += i) d[j].push_back(i); }
int n, m;
ll Bit[maxn]; voidadd(int i, int v){ while (i <= n) Bit[i] += v, i += lowbit(i); }
ll get_sum(int i){ ll s = 0; while (i) s += Bit[i], i -= lowbit(i); return s; }
inlinevoidsolve_1(){ int x, y, z; cin >> x >> y >> z; if (x % y) return ; for (auto t : d[x / y]) add(t * y, mu[t] * z); }
inlinevoidsolve_2(){ int x; cin >> x; ll ans = 0; for (int l = 1, r; l <= x; l = r + 1) { r = x / (x / l); ans += x / l * (get_sum(r) - get_sum(l - 1)); } cout << ans << "\n"; }
int icase; voidwork(){ cout << "Case #" << ++icase << ":\n"; for (int i = 1; i <= n; ++i) Bit[i] = 0; for (int i = 1; i <= m; ++i) { int opt; cin >> opt; if (opt == 1) solve_1(); else solve_2(); } }