当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6259:Rikka with Lines

题目描述
Plane geometry is an important branch of elementary mathematics. When Rikka was a middle school student, she learns a lot of theories about lines, triangles, and circles.

As the time goes on, Rikka has learned a lot of more profound knowledge of mathematics, but she finds that the tasks about lines, triangles, and circles appear less and less. Rikka loves plane geometry because it is simple enough even for a middle school student and is interesting: she misses them very much.

So, Rikka wants to come up with some tasks about lines for herself. She draws $n$ lines $y = a_ix+b_i$ on the two-dimensional Cartesian coordinate system. And then she gives a rectangle with the left bottom corner $(x_1,y_1)$ and the right top corner $(x_2,y_2)$. She wants to count the number of the line pairs $(i,j)(i <j)$ which satisfies their cross point (if exists) is inside the rectangle (including the boundary).

It is a simple task for Rikka, and she wants to test you. To show your mathematics skill, you need to solve this task as soon as possible.

输入解释
The first line contains a single integer $t(1 \leq t \leq 10^3)$, the number of the testcases.

For each testcase, the first line contains five single integers $n,x_1,y_1,x_2,y_2$ which satisfy 1$ \leq n \leq 10^5$ and $-10^{9} \leq x_1 < x_2 \leq 10^9, -10^{18} \leq y_1 < y_2 \leq 10^{18}$.

And then $n$ lines follow, each line contains two integers $a_i,b_i(-10^9 \leq a_i \leq 10^9, a_i \neq 0, -10^{16} \leq b_i \leq 10^{16})$, describing a line.

The input guarantees that each line is unique and there are at most $5$ testcases with $n > 500$.
输出解释
For each testcase, output a single line with a single number, the answer.

输入样例
1
4 0 0 2 2
2 -1
1 0
-1 2
2 2
输出样例
4
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6259

最后修改于 2020-10-25T23:29:46+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/5000MS(Java/Others) 512000/512000K(Java/Others)