All Tracks Math Problem

Destroying houses
Tag(s):

Easy-Medium, Expectation, Geometry, Probability

Problem
Editorial
Analytics

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 $$i^{\text{th}}$$ line contains two integers $$x_i$$, and $$y_i$$, representing $$x$$ and $$y$$ coordinates of the $$i^{\text{th}}$$ 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,x_i,y_i$$ are integers
$$1 \le n,D,R \le 10^6$$
$$ -10^6 \le x_i,y_i \le 10^6$$

SAMPLE INPUT
1 2 1
0 0
SAMPLE OUTPUT
1.0000
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$$.

Time Limit: 3.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Scala 2.11.8, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

August Circuits

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications