Advertisement
Guest User

Untitled

a guest
May 26th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5.  
  6. int dist1(int a, int x, int N)
  7. {
  8.     if(x>=a)
  9.     {
  10.         return x-a;
  11.     }
  12.     else
  13.     {
  14.         return N-a+x;
  15.     }
  16. }
  17.  
  18. int dist2(int b, int y, int N)
  19. {
  20.     if(b>=y)
  21.     {
  22.         return b-y;
  23.     }
  24.     else
  25.     {
  26.         return b+N-y;
  27.     }
  28. }
  29.  
  30. int main()
  31. {
  32.     int N;
  33.     int a;
  34.     int x;
  35.     int b;
  36.     int y;
  37.     cin >> N;
  38.     cin >> a;
  39.     cin >> x;
  40.     cin >> b;
  41.     cin >> y;
  42.     int dist_x;
  43.     int dist_y;
  44.     dist_x=dist1(a,x, N);
  45.     dist_y=dist2(b,y, N);
  46.     float c = float(a)+float(b);
  47.     float a1 = c/2;
  48.     float a2 = (c+N)/2;
  49.     float a3 = (c-N)/2;
  50.     if(floor(a1)==a1 && dist1(a, int(a1), N) <= dist_x && dist1(a, int(a1), N)<=dist_y)
  51.     {
  52.         cout << "YES";
  53.         return 0;
  54.     }
  55.     if(floor(a2)==a2 && dist1(a, int(a2), N) <= dist_x && dist1(a, int(a2), N)<=dist_y)
  56.     {
  57.         cout << "YES";
  58.         return 0;
  59.     }
  60.     if(floor(a3)==a3 && dist1(a, int(a3), N) <= dist_x && dist1(a, int(a3), N)<=dist_y)
  61.     {
  62.         cout << "YES";
  63.         return 0;
  64.     }
  65.     cout << "NO";
  66.     return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement