Destroying houses

3.8

20 votes
Geometry, Exception handling, Easy-Medium, Mathematics, Circle, Probability and Statistics, Geometry
Problem

Hackerland has n houses in the xy plane . You are given x and y coordinates of all the n houses. You plan to drop a bomb on hackerland. The bomb you possess has a destruction radius of D . Formally, if you drop the bomb at point (a,b), all houses within a distance D from this point will be destroyed. You decide to drop the bomb at a point selected uniformly randomly inside a circle of radius R, centered at (0,0). Find the expected value of the number of houses destroyed by the bomb.

Input
The first line contains n, D, and R respectively.
It is followed by n lines.The ith line contains two integers xi, and yi, representing x and y coordinates of the ith house.

Output
Output a single line containing the expected value of number of houses destroyed by the bomb to exactly 4 digits after the decimal point. This is equivalent to printf("%.4lf", value) in C.

Constraints
n,D,R,xi,yi are integers
1n,D,R106
106xi,yi106

Time Limit: 3
Memory Limit: 256
Source Limit:
Explanation

Because D=2, and R=1, no matter where you drop the bomb inside a circle of radius R centered at (0,0), the point (0,0) will always be destroyed. So one house is destroyed no matter where the bomb is dropped. Hence, expected value of number of houses destroyed is 1.

Editor Image

?