Go to diff to previous submission
#include <stdio.h> #include <stdlib.h> #include <algorithm> using namespace std; #include <math.h> #define REP(A,B) for(int A=0; A<B;A++) int X[11111], Y[11111]; double XX[11111], YY[11111]; int main() { int N; while(scanf("%d", &N) == 1) { double ans = 10e12; REP(i, N) scanf("%d %d", X+i, Y+i); for(double ang = 0; ang < 90; ang+=0.05) { REP(i, N) { double q = atan2(Y[i], X[i]); double len = sqrt((double)X[i]*X[i]+(double)Y[i]*Y[i]); q+=ang; XX[i] = len*cos(q); YY[i] = len*sin(q); } double xmin=20000,xmax=-20000,ymin=20000,ymax=-20000; REP(i, N) { xmin = min(XX[i], xmin); xmax = max(XX[i], xmax); ymin = min(YY[i], ymin); ymax = max(YY[i], ymax); } ans = min(2*(xmax-xmin+ymax-ymin), ans); // printf("for ang=%lf: %lf\n", ang, 2*(xmax-xmin+ymax-ymin)); } printf("%.6lf\n", ans); } return 0; }
--- c5.s853.cteam042.fo.cpp.0.fo.cpp +++ c5.s854.cteam042.fo.cpp.0.fo.cpp @@ -12,5 +12,5 @@ double ans = 10e12; REP(i, N) scanf("%d %d", X+i, Y+i); - for(double ang = 0; ang < 90; ang+=0.01) { + for(double ang = 0; ang < 90; ang+=0.05) { REP(i, N) { double q = atan2(Y[i], X[i]);