#include #include #include #include #include using namespace std; typedef long double ldouble; vector shadow; ldouble getLength(ldouble x[], ldouble y[], ldouble theta, int n) { const ldouble cost = cosl(theta); const ldouble sint = sinl(theta); for( int i = 0 ; i < n ; ++i ) { shadow[i] = x[i] * sint + y[i] * cost; } sort(shadow.begin(), shadow.end()); ldouble length = 0.0L, min = shadow[0] - 1.0L, max = shadow[0] + 1.0L; for( int i = 1 ; i < n ; ++i ) { if( shadow[i] > max + 1.0L ) { length += max - min; min = shadow[i] - 1.0L; } max = shadow[i] + 1.0L; } length += max - min; return length; } int main(void) { const ldouble pi = acosl(-1.0); const ldouble epsilon = 1.0e-13L; const ldouble ratio = 1.0e-2L; cout.precision(16); int n; while( cin >> n ) { if( !n ) break; ldouble x[n], y[n]; for( int i = 0 ; i < n ; ++i ) cin >> x[i] >> y[i]; shadow.resize(n); ldouble upperlimit, lowerlimit; ldouble max, min, maxTheta, minTheta; lowerlimit = 0.0L; upperlimit = pi; max = -1.0; while( upperlimit - lowerlimit > epsilon ) { ldouble dTheta = (upperlimit - lowerlimit) * ratio; for( ldouble theta = lowerlimit ; theta <= upperlimit ; theta += dTheta ) { ldouble length = getLength(x, y, theta, n); if( length > max ) { max = length; maxTheta = theta; } } upperlimit = maxTheta + dTheta; lowerlimit = maxTheta - dTheta; if( upperlimit > pi ) upperlimit = pi; if( lowerlimit < 0.0L ) lowerlimit = 0.0L; } lowerlimit = 0.0L; upperlimit = pi; min = max; while( upperlimit - lowerlimit > epsilon ) { ldouble dTheta = (upperlimit - lowerlimit) * ratio; for( ldouble theta = lowerlimit ; theta <= upperlimit ; theta += dTheta ) { ldouble length = getLength(x, y, theta, n); if( length < min ) { min = length; minTheta = theta; } } upperlimit = minTheta + dTheta; lowerlimit = minTheta - dTheta; if( upperlimit > pi ) upperlimit = pi; if( lowerlimit < 0.0L ) lowerlimit = 0.0L; } cout << minTheta << endl << maxTheta << endl; } return 0; }