Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool reachingPoints(int sx, int sy, int tx, int ty) {
- while (tx >= 0 && ty >= 0)
- {
- if (tx < sx || ty < sy)return false;
- if (ty > tx)
- {
- ty %= tx;
- if (tx == sx && sy > ty && (sy - ty) % tx == 0)return true;
- }
- else
- {
- tx %= ty;
- if (ty == sy && sx > tx && (sx - tx) % ty == 0)return true;
- }
- }
- return false;
- }
- };
Add Comment
Please, Sign In to add comment