отрезок
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)
Напишу на С++
Объяснение:
#include <iostream>
using namespace std;
int main() {
setlocale(LC_ALL, "ru");
cout << "Введите первое число<< endl;
int number_one = 0;
cin >> number_one;
cout << "Введите второе число<< endl;
int number_two = 0;
cin >> number_two;
cout << "Введите третье число<< endl;
int number_three = 0;
cin >> number_three;
cout << "Сумма этих чисел - << number_one + number_two + number_three << endl;
cout << "Разность - " << number_one - number_two - number_three << endl;
double answer = 0;
double = number_one / number_two / number_three;
cout << "Частное - " << double;
}
отрезок
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)
Напишу на С++
Объяснение:
#include <iostream>
using namespace std;
int main() {
setlocale(LC_ALL, "ru");
cout << "Введите первое число<< endl;
int number_one = 0;
cin >> number_one;
cout << "Введите второе число<< endl;
int number_two = 0;
cin >> number_two;
cout << "Введите третье число<< endl;
int number_three = 0;
cin >> number_three;
cout << "Сумма этих чисел - << number_one + number_two + number_three << endl;
cout << "Разность - " << number_one - number_two - number_three << endl;
double answer = 0;
double = number_one / number_two / number_three;
cout << "Частное - " << double;
}