init
This commit is contained in:
commit
851751ea87
82 changed files with 2093 additions and 0 deletions
32
8A.py
Normal file
32
8A.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import sys
|
||||
|
||||
data = sys.stdin.read().split()
|
||||
a = int(data[0])
|
||||
b = int(data[1])
|
||||
c = int(data[2])
|
||||
|
||||
x0, x1 = 1, 0
|
||||
y0, y1 = 0, 1
|
||||
temp_a, temp_b = a, b
|
||||
|
||||
while temp_b != 0:
|
||||
q = temp_a // temp_b
|
||||
temp_a, temp_b = temp_b, temp_a % temp_b
|
||||
x0, x1 = x1, x0 - q * x1
|
||||
y0, y1 = y1, y0 - q * y1
|
||||
|
||||
g = temp_a
|
||||
x = x0
|
||||
y = y0
|
||||
|
||||
if c % g != 0:
|
||||
print("Impossible")
|
||||
else:
|
||||
x *= c // g
|
||||
y *= c // g
|
||||
step = b // g
|
||||
x = x % step
|
||||
if x < 0:
|
||||
x += step
|
||||
y = (c - a * x) // b
|
||||
print(x, y)
|
||||
Loading…
Add table
Add a link
Reference in a new issue