отрезок
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)
что-то типа этого:
const n = 8, m = 8;
var
A: array[1..n,1..m] of integer;
i, j, sum, product: integer;
isnotnull: boolean;
begin
randomize;
writeln('Случайная матрица:'); for i:=1 to n do begin
for j:=1 to m do begin
A[i,j] := random(51) - 25;
write(A[i,j]:5);
end;
writeln;
end; sum := 0;
for i:=1 to n do
if A[i,n-i+1] < 0 then
sum := sum + A[i,n-i+1];
writeln('Сумма отрицательных элементов побочной диагонали = ', sum); product := 1;
isnotnull := False;
for i:=1 to n-1 do
for j:=2 to n do
if (j > i) and (A[i,j] <> 0) then begin
isnotnull := True;
product := product * A[i,j];
end;
if isnotnull
writeln('Произведение ненулевых элементов в области выше главной диагонали = ', product)
else
writeln('Ненулевых элементов в области выше главной диагонали нет.', product); readln;
end.