void test(quaternion q) {
if (q.intnorm2() > R) return;
if (q == quaternion()) return;
quaternion unit, res;
unit = quaternion(0, 1, 0, 0); res = q * unit * q.conj();
int a = std::abs(res.x) + std::abs(res.y) + std::abs(res.z);
unit = quaternion(0, 0, 1, 0); res = q * unit * q.conj();
int b = std::abs(res.x) + std::abs(res.y) + std::abs(res.z);
unit = quaternion(0, 0, 0, 1); res = q * unit * q.conj();
int c = std::abs(res.x) + std::abs(res.y) + std::abs(res.z);
static const int coefs[4] = {6, 1, 2, 3};
int coef;
if (q.s > fabsl(q.x) + fabsl(q.y) + fabsl(q.z)) coef = 6;
else coef = coefs[!!q.x + !!q.y + !!q.z];
for (int i = 1; i <= (R - 1) / std::max({a, b, c}); ++i)
if (sqfree[i]) {
int u = a * i, v = b * i, w = c * i, p = std::max({u, v, w}) + 1;
coe[p][3] += coef;
coe[p][2] -= (u + v + w) * coef;
coe[p][1] += (u * (ll)v + v * (ll)w + w * (ll)u) * coef;
coe[p][0] -= u * (ll)v * w * coef;
}
}
std::ostream& operator<<(std::ostream& os, __int128 x) {
if (x / 10) os << (x / 10);
return os << int(x % 10);
}
int main() {
std::cin >> R;
std::fill(sqfree + 1, sqfree + R + 1, 1);
for (int i = 2; i <= R; i += 2) sqfree[i] = 0;
for (int i = 2; i * i <= R; ++i)
for (int j = i * i; j <= R; j += i * i)
sqfree[j] = 0;
int rt = ceil(sqrt(R)) + 1;
for (int s = 1; s <= rt; ++s) {
fprintf(stderr, "[%ld] s = %d\n", clock(), s);
for (int x = -s; x <= s; ++x) {
int yz_lim = s - abs(x);
for (int y = -yz_lim; y <= yz_lim; ++y) {
int z_lim = yz_lim - abs(y);
for (int z = -z_lim; z <= z_lim; ++z)
test(quaternion(s, x, y, z));
}
}
for (int x = ~s; x <= s; ++x) {
int yz_lim = s - (x >= 0 ? x : ~x);
for (int y = -yz_lim; y < yz_lim; ++y) {
int z_lim = yz_lim - (y >= 0 ? y : ~y);
for (int z = -z_lim; z < z_lim; ++z)
test(quaternion(s + .5l, x + .5l, y + .5l, z + .5l));
}
}
}
for (int i = 1; i <= R; ++i) {
__int128 ans = 0;
for (int j = 3; j >= 0; --j) ans = (ans * i + (coe[i][j] += coe[i - 1][j]));
std::cout << i << " " << ans / 6 << '\n';
}
return 0;
}剪贴板
剪贴板 qn8vpz8u
剪贴板信息
剪贴板信息
- 收录
- 更新