<p>Given four integers <code>sx</code>, <code>sy</code>, <code>tx</code>, and <code>ty</code>, return <code>true</code><em> if it is possible to convert the point </em><code>(sx, sy)</code><em> to the point </em><code>(tx, ty)</code> <em>through some operations</em><em>, or </em><code>false</code><em> otherwise</em>.</p>

<p>The allowed operation on some point <code>(x, y)</code> is to convert it to either <code>(x, x + y)</code> or <code>(x + y, y)</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> sx = 1, sy = 1, tx = 3, ty = 5
<strong>Output:</strong> true
<strong>Explanation:</strong>
One series of moves that transforms the starting point to the target is:
(1, 1) -&gt; (1, 2)
(1, 2) -&gt; (3, 2)
(3, 2) -&gt; (3, 5)
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> sx = 1, sy = 1, tx = 2, ty = 2
<strong>Output:</strong> false
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> sx = 1, sy = 1, tx = 1, ty = 1
<strong>Output:</strong> true
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= sx, sy, tx, ty &lt;= 10<sup>9</sup></code></li>
</ul>

class Solution:
    def reachingPoints(self, sx: int, sy: int, tx: int, ty: int) -> bool:
        memo={}

        def f(tx,ty):
            if tx<sx or ty<sy:
                
                return False
            if tx==sx and ty==sy:
                return True
            if tx==sx:
                result=((ty-sy)%tx==0)
                memo[(tx,ty)]=result
                return memo[(tx,ty)]
            if ty==sy:
                result = ((tx-sx)%ty==0)
                memo[(tx,ty)]=result
                return memo[(tx,ty)]
            if tx>ty:
                result = f(tx%ty,ty)
                memo[(tx,ty)]=result
                return memo[(tx,ty)]
            elif ty>tx:
                result=f(tx,ty%tx)
                memo[(tx,ty)]=result
                return memo[(tx,ty)]
            else:
                result =f(tx,0) or f(0,ty)
                memo[(tx,ty)]=result
                return memo[(tx,ty)]
            
            
        return f(tx,ty)
        
16000