class Solution { public boolean reachingPoints(int sx, int sy, int tx, int ty) { while (tx >= sx && ty >= sy) { if (tx == ty) { break; } if (tx > ty) { if (ty > sy) { tx %= ty; } else { return (tx - sx) % ty == 0; } } else { if (tx > sx) { ty %= tx; } else { return (ty - sy) % tx == 0; } } } return tx == sx && ty == sy; } }

判断能否到达目标点:无穷大网格图上的移动问题

原文地址: https://www.cveoy.top/t/topic/nPSq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录