Guest User

Untitled

a guest
Feb 25th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. class Solution {
  2. public:
  3. bool reachingPoints(int sx, int sy, int tx, int ty) {
  4. while (tx >= 0 && ty >= 0)
  5. {
  6. if (tx < sx || ty < sy)return false;
  7. if (ty > tx)
  8. {
  9. ty %= tx;
  10. if (tx == sx && sy > ty && (sy - ty) % tx == 0)return true;
  11. }
  12. else
  13. {
  14. tx %= ty;
  15. if (ty == sy && sx > tx && (sx - tx) % ty == 0)return true;
  16. }
  17. }
  18. return false;
  19. }
  20. };
Add Comment
Please, Sign In to add comment