SHARE
TWEET

Untitled

a guest May 23rd, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. typedef long long unsigned big;
  5.  
  6. big hcf(big a, big b) {
  7.     while (b) {
  8.         big temp = a;
  9.         a = b;
  10.         b = temp % b;
  11.     }
  12.     return a;
  13. }
  14.  
  15. int main() {
  16.     big x, y, x1, y1, x2, y2, h;
  17.     cin >> x >> y;
  18.     h = hcf(x, y);
  19.     x = x / h;
  20.     y = y / h;
  21.     cin >> x1 >> y1 >> x2 >> y2;
  22.  
  23.     for (big i = 0; i < h - 1; i++) {
  24.         big bigX = x + i * x;
  25.         big bigY = y + i * y;
  26.  
  27.         if (!(bigX >= x1 && bigX <= x2 && bigY >= y1 && bigY <= x2)) {
  28.             cout << "No" << endl << bigX <<  " " << bigY << endl;
  29.             return 0;
  30.         }
  31.     }
  32.     cout << "Yes" << endl;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top