题目链接:LightOJ 1203
Problem Description
Once there was a lazy monkey in a forest. But he loved banana too much. One day there was a storm in the jungle and all the bananas fell from the trees. The monkey didn’t want to lose any of the bananas. So, he wanted to find a banana such that he can eat that and he can also look after the other bananas. As he was lazy, he didn’t want to move his eyes too wide. So, you have to help him finding the banana from where he can look after all the bananas but the degree of rotating his eyes is as small as possible. You can assume that the position of the bananas can be modeled as 2D points.
Here a banana is shown, from where the monkey can look after all the bananas with minimum eye rotation.
Input
Input starts with an integer $T (\le 13)$, denoting the number of test cases.
Each case starts with a line containing an integer $n (1 \le n \le 105)$ denoting the number of bananas. Each of the next $n$ lines contains two integers $x y (-10^9 \le x, y \le 10^9)$ denoting the co-ordinate of a banana. There can me more than one bananas in the same co-ordinate.
Output
For each case, print the case number and the minimum angle in degrees. Errors less than $10^-6$ will be ignored.
Sample Input
1 | 2 |
Sample Output
1 | Case 1: 0 |
Note
Dataset is huge. Use faster I/O methods.
Solution
题意:
给定若干个点的坐标,求凸包最小顶角。
思路
凸包
先求凸包,然后枚举所有顶角求最小值。
顶角求法:用两个向量的夹角求
$\angle BAC$ 为向量 $\overrightarrow {AB}$ 与 $\overrightarrow {AC}$ 的夹角:
Code
1 |
|