Source code for submission s853

fo.cpp

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <algorithm>
  4. using namespace std;
  5. #include <math.h>
  6. #define REP(A,B) for(int A=0; A<B;A++)
  7. int X[11111], Y[11111];
  8. double XX[11111], YY[11111];
  9. int main() {
  10. int N;
  11. while(scanf("%d", &N) == 1) {
  12. double ans = 10e12;
  13. REP(i, N) scanf("%d %d", X+i, Y+i);
  14. for(double ang = 0; ang < 90; ang+=0.01) {
  15. REP(i, N) {
  16. double q = atan2(Y[i], X[i]);
  17. double len = sqrt((double)X[i]*X[i]+(double)Y[i]*Y[i]);
  18. q+=ang;
  19. XX[i] = len*cos(q);
  20. YY[i] = len*sin(q);
  21. }
  22. double xmin=20000,xmax=-20000,ymin=20000,ymax=-20000;
  23. REP(i, N) {
  24. xmin = min(XX[i], xmin);
  25. xmax = max(XX[i], xmax);
  26. ymin = min(YY[i], ymin);
  27. ymax = max(YY[i], ymax);
  28. }
  29. ans = min(2*(xmax-xmin+ymax-ymin), ans);
  30. // printf("for ang=%lf: %lf\n", ang, 2*(xmax-xmin+ymax-ymin));
  31. }
  32. printf("%.6lf\n", ans);
  33. }
  34. return 0;
  35. }
  36.