QOJ.ac

QOJ

Süre Sınırı: 1 s Bellek Sınırı: 256 MB Toplam puan: 100 Hack'lenebilir ✓

#18954. Snake

İstatistikler

Summer is here, and it is again the season for the snake to go out foraging.

The snake lives on a two-dimensional plane and is located at the origin $(0,0)$. There are $n$ food items on the plane; the $i$-th food item is at integer coordinates $(x_i,y_i)$. It is guaranteed that no food item is at the origin.

The snake's foraging method is very special:

  1. First, choose an angular interval $[\alpha,\beta]$ centered at the origin.
  2. Using the origin as the vertex, open a sector whose central angle is this interval; the sector keeps expanding outward until all food items within this angular interval (including the boundary) are swallowed in one bite.

The area of the sector is the energy consumed by the snake in this meal.

The snake is very hungry now. It wants to know: to eat at least $k$ food items in one bite, what is the minimum energy required?

Input

The first line contains an integer $t$ ($1\le t\le 10^4$), the number of test cases. It is guaranteed that the sum of $n$ over all test cases does not exceed $2\times 10^5$.

For each test case:

The first line contains two integers $n,k$ ($1\le k\le n\le 2\times 10^5$), denoting the total number of food items and the minimum number of food items that must be eaten, respectively.

The next $n$ lines each contain two integers $x_i,y_i$ ($|x_i|,|y_i|\le 10^6$), the coordinates of the $i$-th food item. It is guaranteed that $(x_i,y_i)\ne(0,0)$.

Output

For each test case, output one real number on a single line, representing the minimum required energy.

Your answer is considered correct if its absolute error or relative error from the standard answer does not exceed $10^{-9}$.

Examples

Input 1

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

Output 1

0.000000000000
2.356194490192

Note

For the first test case, there is only one food item and $k=1$. Choose an angular interval that contains exactly the direction of that food item; the sector degenerates into a line segment from the origin, so its area is $0$.

For the second test case, the optimal strategy is to cover the food items at $(-1,-1)$ and $(1,0)$. The minimum energy is $\frac{1}{2} \times \frac{3\pi}{4} \times 2 = \frac{3\pi}{4}$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.