Each person had do something foolish along with his or her growth.But,when he or she did this that time,they could not predict that this thing is a mistake and they will want this thing would rather not happened.
The world king Sconbin is not the exception.One day,Sconbin was sleeping,then swakened by one nightmare.It turned out that his love letters to Dufein were made public in his dream.These foolish letters might ruin his throne.Sconbin decided to destroy the letters by the military exercises’s opportunity.The missile is the best weapon.Considered the execution of the missile,Sconbin chose to use one missile with the minimum destruction.
Sconbin had writen N letters to Dufein, she buried these letters on different places.Sconbin got the places by difficult,he wants to know where is the best place launch the missile,and the smallest radius of the burst area. Let’s help Sconbin to get the award.
There are many test cases.Each case consists of a positive integer N(N<500,^V^,our great king might be a considerate lover) on a line followed by N lines giving the coordinates of N letters.Each coordinates have two numbers,x coordinate and y coordinate.N=0 is the end of the input file.
For each case,there should be a single line in the output,containing three numbers,the first and second are x and y coordinates of the missile to launch,the third is the smallest radius the missile need to destroy all N letters.All output numbers are rounded to the second digit after the decimal point.
2.00 2.00 1.41
- 随机增量法是一个可以在 期望 O(n)时间内求出最小圆覆盖的算法，首先它的算法流程是这样的
- 枚举第一个点 i，若不在目前圆内，设它为圆心
- 枚举第二个点 j，若不在当前圆内，设当前圆为以 i,j 为直径的圆
- 枚举第三个点 k，若不在当前圆内，设当前圆为 i,j,k 的外接圆
这是一个重点，这么做看似是O(n^3) 的，不过对于随机顺序的点，是可以期望O(n) 的。下面考虑证明：
显然，最后一层循环枚举从 1~j，只要进入循环就一定要跑完，所以是O(j) 的
考虑倒数第二层循环，什么情况下会进入第三层循环呢？仅当 j 不在前 j-1 个点形成的圆中，考虑 j 个点形成的圆是由三个点确定的，那么第 j 个 (最后一个点) 若是三个点之一，则需要扩大圆，否则不需要进入第三层循环，这个概率是3/j 的，所以第二层的复杂度是O(i) 的同理，第一层的复杂度就是O(n)的了