-
-
Save stmtk1/0a510fde34b42630b43e3e0eeecdf45d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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