Skip to content

Instantly share code, notes, and snippets.

@sehajyang
Last active June 18, 2019 06:03
Show Gist options
  • Save sehajyang/3594db055dd1f110b3566837d20ec2d9 to your computer and use it in GitHub Desktop.
Save sehajyang/3594db055dd1f110b3566837d20ec2d9 to your computer and use it in GitHub Desktop.
def solution(a, b, tc, tf):
b_minus_a = b - a
tf_minus_tca = tf - (tc * a)
# 해 2개이상이거나 없는
if a == b:
if a + b == tf and tc == 2:
return '1 1'
return '-1'
elif b_minus_a != 0:
if tf_minus_tca % b_minus_a == 0:
y = tf_minus_tca / b_minus_a
x = tc - y
if x < 1 or y < 1:
return '-1'
else:
return f'{int(x)} {int(y)}'
return '-1'
if __name__ == '__main__':
ll = input().split()
print(solution(int(ll[0]), int(ll[1]), int(ll[2]), int(ll[3])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment