Hard challengeTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 982 Accepted Submission(s): 405
Problem Description
There are
n
points on the plane, and the
i
th points has a value
vali
, and its coordinate is
(xi,yi)
. It is guaranteed that no two points have the same coordinate, and no two points makes the line which passes them also passes the origin point. For every two points, there is a segment connecting them, and the segment has a value which equals the product of the values of the two points. Now HazelFan want to draw a line throgh the origin point but not through any given points, and he define the score is the sum of the values of all segments that the line crosses. Please tell him the maximum score.
Input
The first line contains a positive integer
T(1≤T≤5)
, denoting the number of test cases.
For each test case: The first line contains a positive integer n(1≤n≤5×104) . The next n lines, the i th line contains three integers xi,yi,vali(|xi|,|yi|≤109,1≤vali≤104) .
Output
For each test case:
A single line contains a nonnegative integer, denoting the answer.
Sample Input
Sample Output
Source
本题就是要在给定的点和权值的基础上 在坐标系中画一条直线
然后求这个直线所穿过的边权最大是多少
边权=两边的点权之积求和
仔细想想其实这道题 相当于把坐标系中的点分为两部分 然后对分别把两边的点求和再乘起来
因为 假设 在两边 分别有点权为a1a2和b1b2的点
那么 其边权为a1*b1+
a2*b2 +
a2*b1+a1*b2 = (a1+a2)*(b1*b2)
所以我们 按照极角排序然后遍历求解 一开始用atan2无线wa
后来改用atan后ac
所以以后一个不行的时候换换另一个
现在还是不太明白为什么一定要按照极角排序扫 或是一定要按照atan排序扫才能AC
|
HDU 6127 Hard challenge 计算几何 极角排序
最新推荐文章于 2018-08-02 14:47:48 发布