HDU 1577(WisKey的眼神)

    技术2024-11-03  31

    #include <iostream> #include <cmath> using namespace std; int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); } int main() { int L, sx, sy, dx, dy; while (cin >> L) { if (L == 0) break; cin >> sx >> sy >> dx >> dy; if (abs(dx) > L || abs(dy) > L) cout << "Out Of Range" << endl; else if (gcd(abs(sx - dx), abs(sy - dy)) != 1 || (sx == dx && abs(dy - sy) != 1) || (sy == dy && abs(sx - dx) != 1)) cout << "No" << endl; else cout << "Yes" << endl; } return 0; }

     

    Processed: 0.009, SQL: 9