Untitled

 avatar
unknown
python
3 years ago
490 B
6
Indexable
def compute(sx: int, sy: int, tx: int, ty: int) -> bool:
    while(tx>=sx and ty>=sy):

        if tx == sx and ty == sy:
            return 'Yes'
        # check how many tx we can deduct 
        if ty>tx and (ty-sy)//tx>=1:
            ty=ty - tx*((ty-sy)//tx)
        # check how many ty we can deduct
        elif tx>ty and (tx-sx)//ty>=1:
            tx=tx - ty*((tx-sx)//ty)
        else:
            break
    return 'No'

def isPossible(a, b, c, d):
    return compute(a, b, c, d)
Editor is loading...