Laser Avoidance

You start at point (0, 0) and must reach point (p, q) on a flat field. Unfortunately there is a number of lasers you have to avoid. Each laser starts at a point (x,y) and shoots out an infinite one directional ray at radian angle θ from the x-axis. Given the position of the lasers, find the shortest path you can take without getting hit by a laser. Input A number of test cases (< 100). For each test case, the first row is the three integer n, the total number of lasers, and the end point (p, q). The next n line, each has two integers x, y and a real number θ, describing the laser as defined above as position of laser and the angle with respect to the x-axis. Note that 0 ≤ n, p, |q|, |x|, |y| ≤ 1000000, θ ∈ [−π, π). Output For each test case, output the answer with 5 digits after decimal, on one line. Sample Input 355 211 312 4 1 -1.5 350 521 522 5 2 -1.5 Sample Output 7.63441 5.00000