-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path0780-ReachingPoints.cs
33 lines (31 loc) · 935 Bytes
/
0780-ReachingPoints.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//-----------------------------------------------------------------------------
// Runtime: 40ms
// Memory Usage: 14.5 MB
// Link: https://leetcode.com/submissions/detail/375108833/
//-----------------------------------------------------------------------------
namespace LeetCode
{
public class _0780_ReachingPoints
{
public bool 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);
}
}
}