Created
September 23, 2018 16:12
-
-
Save belyaev-pa/6071b42a5adec94b7697b2e74fc50cb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def kangaroo(input_str): | |
""" для решения задачи необходимо решить уравнение: | |
x1 + y * v1 = x2 + y * v2, так же проверим условия, | |
и проверим крайние уникальные условия, при которых | |
возникает деление на 0: v2 == v1""" | |
input_list = input_str.split() | |
x1, v1, x2, v2 = map(int, input_list) | |
if x1 < 0 or x1 > x2 or x2 > 10000 or\ | |
v1 < 1 or v1 > 10000 or\ | |
v2 < 1 or v2 > 10000: | |
return 'Constraints violented' | |
if v1 == v2: | |
if x1 == x2: | |
return 'Yes' | |
else: | |
return 'No' | |
else: | |
if (x2 - x1) % (v1 - v2) == 0: | |
return 'Yes' | |
else: | |
return 'No' | |
if __name__ == "__main__": | |
input_str = input("Enter correct number sequence ") | |
print(kangaroo(input_str)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment