Source code for submission s904

Go to diff to previous submission

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. double Q[11111];
  10. double L[11111];
  11. int main() {
  12. int N;
  13. while(scanf("%d", &N) == 1) {
  14. double ans = 10e12;
  15. REP(i, N) {
  16. scanf("%d %d", X+i, Y+i);
  17. L[i] = sqrt((double)X[i]*X[i]+(double)Y[i]*Y[i]);
  18. Q[i] = atan2(Y[i], X[i]);
  19. }
  20.  
  21. for(double ang = -180; ang < 180; ang+=0.5) {
  22. REP(i, N) {
  23. XX[i] = L[i]*cos(Q[i]+ang*M_PI/180);
  24. YY[i] = L[i]*sin(Q[i]+ang*M_PI/180);
  25. }
  26. double xmin=20000,xmax=-20000,ymin=20000,ymax=-20000;
  27. REP(i, N) {
  28. xmin = min(XX[i], xmin);
  29. xmax = max(XX[i], xmax);
  30. ymin = min(YY[i], ymin);
  31. ymax = max(YY[i], ymax);
  32. }
  33. double curr = 2*(xmax-xmin+ymax-ymin);
  34. if(curr < ans) {
  35. ans = curr;
  36. //printf("%lf\n", ang);
  37. }
  38. // printf("for ang=%lf: %lf\n", ang, 2*(xmax-xmin+ymax-ymin));
  39. }
  40. printf("%.6lf\n", ans);
  41. }
  42. return 0;
  43. }
  44.  

Diff to submission s888

fo.cpp

--- c5.s888.cteam042.fo.cpp.0.fo.cpp
+++ c5.s904.cteam042.fo.cpp.0.fo.cpp
@@ -19,5 +19,5 @@
                 }
 
-                for(double ang = 0; ang < 90; ang+=0.5) {
+                for(double ang = -180; ang < 180; ang+=0.5) {
                         REP(i, N) {
                                 XX[i] = L[i]*cos(Q[i]+ang*M_PI/180);