Help Mayor

0

0 votes
Problem

Help Mayor

In city Z, the buildings are orgranized in a block (grid-like) pattern with straight horizontal and vertical roads. The mayor has recieved the news of a missile attack on the city. According to the radars, the only missile in the attack will hit the city at coordinate (x, y). Intelligence predicted an impact radius of k kilometres. Since there is not a lot of time left now, the Mayor wants to evacuate the buildings in the impact zone. 

To devise an effective plan for the evacuation, Mayor wants to the know the number of buildings that lie in the speculated impact zone. Considering the city to be a square grid with origin at (0, 0) and the buildings to be at integral distances from the horizontal and vertical axes, find the number of buildings that need to be evacuated.

For example, a radius of k = 1km and center at (0, 0), 5 buildings ((0, 0), (0, 1), (0, -1), (1, 0), (-1, 0)) would need evacuation and for k = 1.5km and center at (2.5, -1.25), 4 buildings ((2, -1), (3, -1), (2, -2), (3, -2)) would be affected.

Note: Buildings lying on the edge of the zone are also counted as Mayor would not want to take any chances.

Constraints:
    0<=|x|<=105
    0<=∣y∣ ≤ 105
    0 < R ≤ 105
    Each of x,y and R will not have more than 4 digits after decimal Point.

Input:
    3 space separated numbers as follows
    x y R

Output:
    1 integer i.e. number of those buidlings
 

Time Limit: 2
Memory Limit: 1024
Source Limit:
Editor Image

?