Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.84 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. void norm(double& a)
  38. {
  39.     while(a < EPS) a += 2 * PI;
  40.     while(a > 2 * PI - EPS) a -= 2 * PI;
  41. }
  42.  
  43. int main()
  44. {
  45.     //freopen("in.txt", "r", stdin);
  46.     //ios::sync_with_stdio(false); cin.tie(0);
  47.  
  48.     int n;
  49.     while(scanf("%d", &n) != EOF)
  50.     {
  51.         double a;
  52.         scanf("%lf", &a);
  53.         FOR (i, 0, n)
  54.         {
  55.             scanf("%lf", &A[i].x);
  56.         }
  57.  
  58.         FOR (i, 0, n)
  59.         {
  60.             scanf("%lf", &A[i].y);
  61.         }
  62.  
  63.         int cnt = 0;
  64.         vector<pair<double, int> > E;
  65.  
  66.         FOR (i, 0, n)
  67.         {
  68.             if (abs(A[i].x) < 0 && abs(A[i].y) < 0)
  69.             {
  70.                 cnt++;
  71.                 continue;
  72.             }
  73.             double r2 = A[i].x * A[i].x + A[i].y * A[i].y;
  74.             double d = 1 + 4 * a * a * r2;
  75.             double x = (sqrt(d)  - 1) / (2*a);
  76.             double y = sqrt(r2 - x*x);
  77.  
  78.             double a1 = atan2(A[i].y, A[i].x);
  79.             double a2 = atan2(y, x);
  80.  
  81.             double ang1 = a1 - a2;
  82.             double ang2 = a1 + a2;
  83.  
  84.             norm(ang1);
  85.             norm(ang2);
  86.  
  87.             E.PB(MP(ang1 - EPS, 1));
  88.             E.PB(MP(ang2 + EPS, -1));
  89.  
  90.             if (ang1 > ang2) cnt++;
  91.         }
  92.  
  93.         sort(ALL(E));
  94.         int res = cnt;
  95.  
  96.         FOR (i, 0, SZ(E))
  97.         {
  98.             cnt += E[i].second;
  99.             res = max(res, cnt);
  100.         }
  101.  
  102.         printf("%d daze\n", res);
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement