Guest User

Untitled

a guest
Feb 28th, 2013
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. /****************************************
  2. **     Solution by Bekzhan Kassenov    **
  3. ****************************************/
  4.  
  5. #include <iostream>
  6. #include <cstdio>
  7. #include <fstream>
  8. #include <sstream>
  9. #include <string>
  10. #include <vector>
  11. #include <deque>
  12. #include <queue>
  13. #include <stack>
  14. #include <map>
  15. #include <set>
  16. #include <list>
  17. #include <algorithm>
  18. #include <cstdlib>
  19. #include <cmath>
  20. #include <ctime>
  21. #include <iomanip>
  22.  
  23. using namespace std;
  24.  
  25. #define PII pair <int, int>
  26. #define F first
  27. #define S second
  28. #define MP make_pair
  29. #define PB push_back
  30. #define VI vector <int>
  31. #define sqr(x) (x) * (x)
  32. #define INF (int) (2e9)
  33. #define MOD (1000 * 1000 * 1000 + 7)
  34. #define ull unsigned long long
  35. #define ll long long
  36. #define pi 3.1415926535
  37. #define EPS 1e-8
  38.  
  39. int comp(double a, double b)
  40. {
  41.     if (fabs(a - b) < EPS)
  42.         return 0;
  43.  
  44.     if (a - b > EPS)
  45.         return 1;
  46.  
  47.     return -1;
  48. }
  49.  
  50. double angle(double x, double y)
  51. {
  52.     return atan2(y, x);
  53. }
  54.  
  55. int main()
  56. {
  57.     #ifndef ONLINE_JUDGE
  58.         freopen("in", "r", stdin);
  59.     #endif
  60.  
  61.     int n;
  62.  
  63.     cin >> n;
  64.  
  65.     vector <double> a(n);
  66.  
  67.     for (int i = 0; i < n; i++)
  68.         {
  69.             int x, y;
  70.  
  71.             cin >> x >> y;
  72.  
  73.             a[i] = angle(x, y);
  74.  
  75.             if (comp(a[i], 2 * pi) == 0)
  76.                 a[i] = 0;
  77.         }
  78.  
  79.     sort(a.begin(), a.end());
  80.  
  81.     double ans = 10;
  82.  
  83.     //printf("%.6lf ", a[0]);
  84.  
  85.     for (int i = 1; i < n; i++)
  86.         {
  87.             double tmp = 2 * pi - (a[i] - a[i - 1]);
  88.             //printf("%.6lf ", (a[i] * 360) / (2 * pi));
  89.             if (comp(tmp, ans) == -1)
  90.                 ans = tmp;
  91.         }
  92.  
  93.     double tmp = a[n - 1] - a[0];
  94.  
  95.     if (comp(tmp, ans) == -1)
  96.         ans = tmp;
  97.  
  98.     printf("%.6lf", (ans * 360) / (2 * pi));
  99.  
  100.     return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment