/* * solution by Fredrik Haugen */ #include // std::cout #include // std::atol long long gauss_circle(long r) { long long counted_points = 0; long long r2 = r*r; long y = r - 1; long x = 1; while (2 * y*y > r2) if (x*x + y*y <= r2) x++; else { y--; counted_points += x-1; } // exploit symmetry return 4 * (2 * counted_points + (y*y + r)) + 1; } int main(int argc, char** argv) { long r = std::atol(argv[1]); long long N = gauss_circle(r); std::cout << N << "\n"; }