Skip to content

Instantly share code, notes, and snippets.

@stmtk1
Created August 21, 2019 01:33
Show Gist options
  • Save stmtk1/0a510fde34b42630b43e3e0eeecdf45d to your computer and use it in GitHub Desktop.
Save stmtk1/0a510fde34b42630b43e3e0eeecdf45d to your computer and use it in GitHub Desktop.
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def main():
print("input three integers:")
a = int(input())
b = int(input())
c = int(input())
if c % gcd(a, b) != 0:
print("解がありません")
return
g = gcd(a, b)
a = int(a / g)
b = int(b / g)
print([ a * i for i in range(1, b) ])
m = [ i for i in range(1, b) if (a * i) % b == 1 ][0]
n = int((1 - a * m) / b)
print("{} * {} + {} * {} = {}".format(a * g, m * c, b * g, n * c, c))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment