测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10097. Cross Sum

编程题 普及/提高-

题目描述

Genos has been given $n$ distinct lines on the Cartesian plane. Let ![](/uploads/acgo/image/7f66f387ae7b3b20_d0918b63cad4.jpeg) be a list of intersection points of these lines. A single point might appear multiple times in this list if it is the intersection of multiple pairs of lines. The order of the list does not matter.

Given a query point $(p,q)$ , let ![](/uploads/acgo/image/2d5df49fc8a858f8_5b6ad2ff4fa6.jpeg) be the corresponding list of distances of all points in ![](/uploads/acgo/image/7f66f387ae7b3b20_d0918b63cad4.jpeg) to the query point. Distance here refers to euclidean distance. As a refresher, the euclidean distance between two points $(x_{1},y_{1})$ and $(x_{2},y_{2})$ is ![](/uploads/acgo/image/6a51858da92877fe_43b6547fddf1.jpeg).

Genos is given a point $(p,q)$ and a positive integer $m$ . He is asked to find the sum of the $m$ smallest elements in ![](/uploads/acgo/image/2d5df49fc8a858f8_5b6ad2ff4fa6.jpeg). Duplicate elements in ![](/uploads/acgo/image/2d5df49fc8a858f8_5b6ad2ff4fa6.jpeg) are treated as separate elements. Genos is intimidated by Div1 E problems so he asked for your help.

输入格式

The first line of the input contains a single integer $n$ ( $2<=n<=50000$ ) — the number of lines.

The second line contains three integers $x$ , $y$ and $m$ ( $|x|,|y|<=1000000$ , ![](/uploads/luogu/CF607E/8201e41b76d5859818b53fa92521eb060190c840_740f480c965f.png)) — the encoded coordinates of the query point and the integer $m$ from the statement above. The query point $(p,q)$ is obtained as ![](/uploads/luogu/CF607E/ab5ed9d2a6b0c9e268daea47ead56f0338fbfe18_94269ee35c88.png). In other words, divide $x$ and $y$ by $1000$ to get the actual query point. ![](/uploads/luogu/CF607E/10e260f8817511999fbd109fdb87fbea4e756803_f677e9fb73d9.png) denotes the length of the list ![](/uploads/luogu/CF607E/887c79cacd151e1b1341a67c48b05ad1977a6a94_3ca9029c3841.png) and it is guaranteed that ![](/uploads/acgo/image/227faa391c436806_85fd7c7906e1.jpeg).

Each of the next $n$ lines contains two integers $a_{i}$ and $b_{i}$ ( $|a_{i}|,|b_{i}|<=1000000$ ) — the parameters for a line of the form: ![](/uploads/acgo/image/0de2efdbb2aec965_2a2479b5f57b.jpeg). It is guaranteed that no two lines are the same, that is $(a_{i},b_{i})≠(a_{j},b_{j})$ if $i≠j$ .

输出格式

Print a single real number, the sum of $m$ smallest elements of ![](/uploads/acgo/image/a10faedbc9767a8a_6bafd90c2fee.jpeg). Your answer will be considered correct if its absolute or relative error does not exceed $10^{-6}$ .

To clarify, let's assume that your answer is $a$ and the answer of the jury is $b$ . The checker program will consider your answer correct if ![](/uploads/acgo/image/25006765673f1164_70425eadcc9a.jpeg).

输入输出样例

输入 #1
4
1000 1000 3
1000 0
-1000 0
0 5000
0 -5000
输出 #1
14.282170363
输入 #2
2
-1000000 -1000000 1
1000000 -1000000
999999 1000000
输出 #2
2000001000.999999500
输入 #3
3
-1000 1000 3
1000 0
-1000 2000
2000 -1000
输出 #3
6.000000000
输入 #4
5
-303667 189976 10
-638 116487
-581 44337
1231 -756844
1427 -44097
8271 -838417
输出 #4
12953.274911829

说明/提示

In the first sample, the three closest points have distances ![](/uploads/luogu/CF607E/03e1c4be79c9981c15945694583ed8d2e2085b66_f52049d84e0c.png) and ![](/uploads/acgo/image/a15178c989c1b597_4b90f044a7cc.jpeg).

In the second sample, the two lines $y=1000x-1000$ and ![](/uploads/luogu/CF607E/faf029c89031cc072ce6f3860dca6bca047834e2_593b1ebcdbbb.png) intersect at $(2000000,1999999000)$ . This point has a distance of ![](/uploads/acgo/image/96409ffcf8839fe7_bb5d7b05c9e0.jpeg) from $(-1000,-1000)$ .

In the third sample, the three lines all intersect at the point $(1,1)$ . This intersection point is present three times in ![](/uploads/acgo/image/109ab29c0725ccc6_4276f2de8140.jpeg) since it is the intersection of three pairs of lines. Since the distance between the intersection point and the query point is $2$ , the answer is three times that or $6$ .
上一题 去做题 下一题