Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.87 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define FOR(i,a,b) for (int i = (a); i < (b); i++)
  5. #define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
  6. #define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
  7. #define FILL(a,value) memset(a, value, sizeof(a))
  8.  
  9. #define SZ(a) (int)a.size()
  10. #define ALL(a) a.begin(), a.end()
  11. #define PB push_back
  12. #define MP make_pair
  13.  
  14. typedef long long LL;
  15. typedef vector<int> VI;
  16. typedef pair<int, int> PII;
  17.  
  18. const double PI = acos(-1.0);
  19. const int INF = 1000 * 1000 * 1000 + 7;
  20. const LL LINF = INF * (LL) INF;
  21.  
  22. const int MAX = 30300;
  23.  
  24. const double EPS = 1e-7;
  25.  
  26. struct Point
  27. {
  28.     double x, y;
  29.     Point(double x, double y)
  30.     {
  31.         this->x = x;
  32.         this->y = y;
  33.     }
  34.     Point(){}
  35. } A[MAX];
  36.  
  37. int main()
  38. {
  39.     //freopen("in.txt", "r", stdin);
  40.     //ios::sync_with_stdio(false); cin.tie(0);
  41.  
  42.     int n;
  43.     while(scanf("%d", &n) != EOF)
  44.     {
  45.         double a;
  46.         scanf("%lf", &a);
  47.         FOR (i, 0, n)
  48.         {
  49.             scanf("%lf", &A[i].x);
  50.         }
  51.  
  52.         FOR (i, 0, n)
  53.         {
  54.             scanf("%lf", &A[i].y);
  55.         }
  56.  
  57.         int cnt = 0;
  58.         vector<pair<double, int> > E;
  59.  
  60.         FOR (i, 0, n)
  61.         {
  62.             if (abs(A[i].x) < 0 && abs(A[i].y) < 0)
  63.             {
  64.                 cnt++;
  65.                 continue;
  66.             }
  67.             double r2 = A[i].x * A[i].x + A[i].y * A[i].y;
  68.             double d = 1 + 4 * a * a * r2;
  69.             double x = (sqrt(d)  - 1) / (2*a);
  70.  
  71.             double y = sqrt(r2 - x*x);
  72.  
  73.             double a1 = atan2(A[i].y, A[i].x);
  74.             double a2 = atan2(y, x);
  75.  
  76.             double ang1 = a1 - a2;
  77.             double ang2 = a1 + a2;
  78.  
  79.             while(ang1 < EPS) ang1 += 2 * PI;
  80.             while(ang1 > 2*PI - EPS) ang1 -= 2*PI;
  81.  
  82.             while(ang2 < EPS) ang2 += 2 * PI;
  83.             while(ang2 > 2*PI - EPS) ang2 -= 2*PI;
  84.  
  85.             E.PB(MP(ang1 - EPS, 1));
  86.             E.PB(MP(ang2 + EPS, -1));
  87.  
  88.             if (ang1 > ang2) cnt++;
  89.         }
  90.  
  91.         sort(ALL(E));
  92.         int res = cnt;
  93.  
  94.         FOR (i, 0, SZ(E))
  95.         {
  96.             cnt += E[i].second;
  97.             res = max(res, cnt);
  98.         }
  99.  
  100.         printf("%d daze\n", res);
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement