Pan's Labyrinth Time Limit: 2 seconds memory limit: 65536 kb Special Judge
Ofelia is chased by her edevil stepfather, and now she finds herself lost in a labyrinth. She needs your help to run away from her tragic family.
There's a huge metal door standing in front of the exit of the Labyrinth. There areNDots on the metal door. pan (the god of the labyrinth) asks Ofelia to find out a triangle which has the largest height. the triangle's three vertexes must be the dots on the door, and its area must be positive. ofelia shoshould tell pan the triangle's height so Pan will let Ofelia go.
Input
There are multiple cases (about 100 cases). For each case, the first line contains an integerN(3 <=N<= 500). In the next n lines, each line contains two real numberX [I],Y [I](0 <= x [I], Y [I] <= 10000) which indicates each dot's coordinate. there is no two dots in the same coordinate. the answers are strictly greater than 0.
Output
For each test case, output one line with the maximum triangle height. Any solution with a relative or absolute error of at most 1e-6 will be accepted.
Sample Input
60.000 4.0002.000 4.0001.000 0.0001.000 8.0000.900 7.0001.100 7.00076967.54555 3457.712003.52325 1273.859127755.35733 9812.97643753.00303 2124.709377896.71246 8877.780545832.77264 5213.704784629.38110 8159.01498
Sample output
7.000008940.96643
Hint
In case 1. ChooseDOT 3, 5, 6To make up a triangle, and this triangle has the largest height 7.000.in case 2. We choose dot 2, 3, 5.
# Include <iostream> # include <cstdio> # include <string> # include <algorithm> # include <cmath> using namespace STD; const int maxn = 500 + 5; struct point {Double X, Y; point (double x = 0, Double Y = 0): x (x), y (y) {}}; typedef point vector; double Cross (vector A, vector B) {return. x * B. y-A.y * B. x;} double dot (vector A, vector B) {return. x * B. X +. y * B. y;} double length (vector A) {return SQRT (dot (A, A);} double distanc (point, Point B) {return SQRT (. x-B.x) * (. x-B.x) +. y-B.y) * (. y-B.y);} vector operator-(vector A, vector B) {return vector (. x-B.x,. y-B.y); // was overloaded with pitfall for a morning.} Double distancetoline (point P, point A, point B) {vector u = B-A, V = P-A; return FABS (Cross (u, v )) /length (U);}/* Double dist (point a, point B, point C) {If (B. x! =. X) {Double K = (B. y-a.y)/(B. x-a.x); Return FABS (C. y-a.y)-k x (C. x-a.x)/SQRT (1 + K * k);} else return FABS (C. x-a.x);} */point num [maxn]; int I, j, k; int main () {/* # ifndef online_judge freopen ("in.txt", "r ", stdin); # endif */int n; while (CIN> N) {int K; double high; high = 0.0; for (I = 0; I <N; I ++) scanf ("% lf", & num [I]. x, & num [I]. y); for (I = 0; I <n; I ++) {double mMax = 0.0; For (j = 0; j <n; j ++) {If (j = I) continue; If (distanc (Num [I], num [J])> mMax) {k = J; mMax = distanc (Num [I], num [J]) ;}}for (j = 0; j <n; j ++) {if (I = j | j = k) continue; high = max (high, distancetoline (Num [I], num [J], num [k]); high = max (high, distancetoline (Num [J], num [K], num [I]); high = max (High, distancetoline (Num [K], num [J], num [I]) ;}} printf ("% 0.6f \ n", high);} return 0 ;}
Pan's Labyrinth (find the maximum height of the triangle)