Cod sursa(job #3188609)
Utilizator | Caldarea Ciprian CaldareaCiprian | Data | 3 ianuarie 2024 15:19:13 |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.67 kb |
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void cmmdc(int a, int b, int& x, int& y, int& d)
{
if (b == 0)
{
x = 1;
y = 0;
d = a;
return;
}
int yt, xt;
cmmdc(b, a % b, xt, yt, d);
x = yt;
y = xt - (a / b) * yt;
}
int main()
{
int n, a, b, c;
fin >> n;
while (n--)
{
fin >> a >> b >> c;
int d, x, y;
cmmdc(a, b, x, y, d);
if (c % d != 0)
fout << "0 0\n";
else
fout << c / d * x << ' ' << c / d * y << '\n';
}
return 0;
}