A radar dish covers a circular region of integer radius r centered at the origin of a grid. Count how many integer grid points (x, y) lie inside or exactly on the edge of that region, i.e. how many integer pairs satisfy x*x + y*y <= r*r.
Line 1: a single integer r, the radius.
A single integer: the number of integer grid points covered.
Example 1
Input
0
Expected
1
Explanation
A radius of 0 covers only the origin (0, 0), so the count is 1.
Example 2
Input
2
Expected
13
Explanation
The 13 integer points with x*x + y*y <= 4 are the origin, the four points at distance 1 along the axes, the four points at distance 2 along the axes, and the four diagonal points (+/-1, +/-1).
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →