Skip to content

Instantly share code, notes, and snippets.

@karhunenloeve
Forked from Chgtaxihe/7C.py
Created July 25, 2023 12:42
Show Gist options
  • Save karhunenloeve/632cb2650e08cd179c11f4d25cd73e0a to your computer and use it in GitHub Desktop.
Save karhunenloeve/632cb2650e08cd179c11f4d25cd73e0a 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