题库练习 Cross Sum
← 上一题 下一题 →

A10097 | Cross Sum

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

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
C++ 编辑器
输入
输出