Cod sursa(job #2854207)

Utilizator Solo22Stefan Solomon Solo22 Data 21 februarie 2022 01:05:40
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.56 kb
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int Euclid_extins(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1, y = 0;
		return a;
	}
	else {
		int x0, y0, d;
		d = Euclid_extins(b, a % b, x0, y0);
		x = y0, y = x0 - (a / b) * y0;
	}
}
int t;
int main() {
	cin >> t;
	for (int i = 1, a, b, c, d, x, y; i <= t; ++i) {
		cin >> a >> b >> c, Euclid_extins(a, b, x, y);
		if (c % d == 0)
			cout << x * c / d << " " << y * c / d << "\n";
		else
			cout << 0 << " " << 0 << "\n";
	}
	return 0;
}