• + 0 comments

    A brute-force approach with max_it equal to maximum size works for all test-cases:

    import os
    
    def kangaroo(x1, v1, x2, v2):
        it = 0
        max_it = 10000
        while x1 != x2:
            x1 += v1
            x2 += v2
            if it == max_it:
                return 'NO'
            it += 1
        return 'YES'
        
    if __name__ == '__main__':
        fptr = open(os.environ['OUTPUT_PATH'], 'w')
    
        first_multiple_input = input().rstrip().split()
    
        x1 = int(first_multiple_input[0])
    
        v1 = int(first_multiple_input[1])
    
        x2 = int(first_multiple_input[2])
    
        v2 = int(first_multiple_input[3])
    
        result = kangaroo(x1, v1, x2, v2)
    
        fptr.write(result + '\n')
    
        fptr.close()