780. Reaching Points
https://leetcode.com/problems/reaching-points/
/*
* @lc app=leetcode id=780 lang=cpp
*
* [780] Reaching Points
*/
// @lc code=start
class Solution {
public:
bool reachingPoints(int sx, int sy, int tx, int ty) {
while (sx <= tx && sy <= ty) {
if (tx < ty) {
ty = ty % tx;
if (ty == sy % sx && sx == tx) {
return true;
}
} else if (tx > ty) {
tx = tx % ty;
if (tx == sx % sy && sy == ty) {
return true;
}
} else {
return sx == sy;
}
}
return false;
}
};
// @lc code=endLast updated