a) 11101110 = 1∙2^7+1∙2^6+1∙2^5+0∙2^4+1∙2^3+1∙2^2+1∙2^1+0∙2^0 = 128+64+32+0+8+4+2+0 = 238
238^2 = 56644
56644 = 1101110101000100
b) 11001100 = 1∙2^7+1∙2^6+0∙2^5+0∙2^4+1∙2^3+1∙2^2+0∙2^1+0∙2^0 = 128+64+0+0+8+4+0+0 = 204
204^2 = 41616
41616 = 1010001010010000
c) 1000010 = 1∙2^6+0∙2^5+0∙2^4+0∙2^3+0∙2^2+1∙2^1+0∙2^0 = 64+0+0+0+0+2+0 = 66
66^2 = 4356
4356 = 1000100000100
d) 10000101 = 1∙2^7+0∙2^6+0∙2^5+0∙2^4+0∙2^3+1∙2^2+0∙2^1+1∙2^0 = 128+0+0+0+0+4+0+1 = 133
133^2 = 17689
17689 = 100010100011001
Знаком " ^" обозначают степени.
(Надеюсь правильно поняла задание)
отрезок
x1, y1,x2,y2 = map(int, input().split())
def nod(a, b):
--if b > 0:
return nod(b, a%b)
--else:
return a
a = abs(x1 - x2)
b = abs(y1 - y2)
d = nod(a, b)
print(d * (a//d + b//d - 1))
уравнение
def gcd(a, b):
while a != 0 and b != 0:
if a < b:
b = b % a
else:
a = a % b
return a + b
def qwer(a, b):
x = 1
x1 = 0
y = 0
y1 = 1
while b != 0:
q = a // b
r = a % b
x2 = x - q * x1
y2 = y - q * y1
a, b = b, r
x, x1 = x1, x2
y, y1 = y1, y2
return str(a), str(x), str(y)
a, b, c = list(map(int, input().split()))
x, y = 0, 0
gcds = 0
if c % gcd(a, b) != 0:
print('-1')
gcds, x, y = map(int, qwer(a, b))
x *= c // gcds
y *= c // gcds
q = x // (b // gcds)
x %= b // gcds
y += a // gcds * q
print(x, y)
a) 11101110 = 1∙2^7+1∙2^6+1∙2^5+0∙2^4+1∙2^3+1∙2^2+1∙2^1+0∙2^0 = 128+64+32+0+8+4+2+0 = 238
238^2 = 56644
56644 = 1101110101000100
b) 11001100 = 1∙2^7+1∙2^6+0∙2^5+0∙2^4+1∙2^3+1∙2^2+0∙2^1+0∙2^0 = 128+64+0+0+8+4+0+0 = 204
204^2 = 41616
41616 = 1010001010010000
c) 1000010 = 1∙2^6+0∙2^5+0∙2^4+0∙2^3+0∙2^2+1∙2^1+0∙2^0 = 64+0+0+0+0+2+0 = 66
66^2 = 4356
4356 = 1000100000100
d) 10000101 = 1∙2^7+0∙2^6+0∙2^5+0∙2^4+0∙2^3+1∙2^2+0∙2^1+1∙2^0 = 128+0+0+0+0+4+0+1 = 133
133^2 = 17689
17689 = 100010100011001
Знаком " ^" обозначают степени.
(Надеюсь правильно поняла задание)
отрезок
x1, y1,x2,y2 = map(int, input().split())
def nod(a, b):
--if b > 0:
return nod(b, a%b)
--else:
return a
a = abs(x1 - x2)
b = abs(y1 - y2)
d = nod(a, b)
print(d * (a//d + b//d - 1))
уравнение
def gcd(a, b):
while a != 0 and b != 0:
if a < b:
b = b % a
else:
a = a % b
return a + b
def qwer(a, b):
x = 1
x1 = 0
y = 0
y1 = 1
while b != 0:
q = a // b
r = a % b
x2 = x - q * x1
y2 = y - q * y1
a, b = b, r
x, x1 = x1, x2
y, y1 = y1, y2
return str(a), str(x), str(y)
a, b, c = list(map(int, input().split()))
x, y = 0, 0
gcds = 0
if c % gcd(a, b) != 0:
print('-1')
else:
gcds, x, y = map(int, qwer(a, b))
x *= c // gcds
y *= c // gcds
q = x // (b // gcds)
x %= b // gcds
y += a // gcds * q
print(x, y)