#P3897. Maximal Selection of Rabbits Without Obstacle Intersection

    ID: 17145 Type: Default 1000ms 256MiB

Maximal Selection of Rabbits Without Obstacle Intersection

Maximal Selection of Rabbits Without Obstacle Intersection

Problem Statement:

Inside their castle, the rabbits have decided to station soldiers for defense. They are given n points in the plane representing rabbit locations and one circular obstacle whose center is at the origin with radius R. The rabbits wish to choose as many rabbits as possible with the property that for any two chosen rabbits, the infinite line passing through their positions does not intersect the circle.

Let a chosen rabbit have polar coordinates ((r,\theta)) (note that only rabbits with (r > R) are eligible, because if a rabbit lies on or inside the circle then the line through it and any other point will intersect the circle). For any two chosen rabbits with coordinates ((r_1,\theta_1)) and ((r_2,\theta_2)), denote (r_{min}=\min(r_1,r_2)) and let (\Delta=|\theta_1-\theta_2|). A useful geometric derivation shows that the infinite line determined by these two points does not intersect the circle if and only if [ r_{min} \cdot \cos\frac{\Delta}{2} > R. ] This condition is equivalent to requiring that [ \Delta < 2\arccos\Bigl(\frac{R}{r_{min}}\Bigr). ]

Your task is to compute the maximum number of rabbits that can be chosen satisfying the condition that for every pair of selected rabbits the line through them does not intersect the circle. Note that even a single rabbit (which trivially meets the condition) is considered valid.

inputFormat

Input Format:

The first line contains two numbers: an integer n ((1 \le n \le 10^3)) and a positive real number R, where R is the radius of the circular obstacle.

Each of the next n lines contains two real numbers x and y representing the coordinates of a rabbit.

outputFormat

Output Format:

Output a single integer representing the maximum number of rabbits that can be chosen such that for every pair of selected rabbits, the infinite line joining them does not intersect the circle.

sample

5 1
2 0
0 2
-2 0
0 -2
3 3
3