Skip to content

Instantly share code, notes, and snippets.

@Chgtaxihe
Created January 9, 2020 07:04
Show Gist options
  • Save Chgtaxihe/62acf30355bbdd914d929a6b83f757d2 to your computer and use it in GitHub Desktop.
Save Chgtaxihe/62acf30355bbdd914d929a6b83f757d2 to your computer and use it in GitHub Desktop.
Codeforces Number Theory #Codeforces
def exgcd(a, b):
if 0 == b:
return 1, 0, a
x, y, q = exgcd(b, a % b)
x, y = y, (x - a // b * y)
return x, y, q
def main():
a, b, c = map(int, input().split())
c = -c
x, y, q = exgcd(a, b)
if c % q == 0:
print("%d %d"%(c//q*x, c//q*y))
else:
print(-1)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment