Cod sursa(job #3326185)

Utilizator nverde1119Popa Narcis Constantin nverde1119 Data 27 noiembrie 2025 17:20:22
Problema Algoritmul lui Euclid extins Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.59 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void euclid(long long a, long long b, long long &d, long long &x, long long &y)
{
	if(b == 0)
		x = 1, y = 0, d = a;
	else
	{
		long long x0, y0;
		euclid(b, a % b, d, x0, y0);
		x = y0;
		y = x0 - (a / b) * y0;
	}
}
int main()
{
	long long a, b, c, d, x, y;
	int t;
	f >> t;
	for(int i = 1; i <= t; i++)
	{
		f >> a >> b >> c;
		euclid(a, b, d, x, y);
		if(c % d)
			g << "0 0\n";
		else
			g << x*(c / d) << ' ' << y*(c / d) << '\n';
	}
	return 0;
}