Circle
Time limit1sMemory limit128 MB
Given grid side k and circle radius r centered at a grid vertex, count cells the circle passes through, excluding cells touched only at a corner.
- Level
Hard8 of 10
- Topics
- Math, Geometry, Number theory, Binary search
- Solved
- No attempts yet
Problem
There is an infinitely large sheet of grid paper made up of square cells. Each cell has a side length of units.
A circle of radius units is drawn on this sheet. The center of the circle lies at the intersection of two grid lines, that is, at the vertex where four cells meet.
Every cell that the circle passes through (every cell that contains a part of the circle) is painted. However, if the circle only touches a single corner of a cell (meeting the cell at that corner alone), that cell is not painted.
Given the natural numbers and , write a program that computes the number of painted cells.
Input
The first line contains two natural numbers and , separated by a space. (, )
Output
Print the number of painted cells on a single line.