Mai intai trebuie sa te autentifici.
Cod sursa(job #2580446)
Utilizator | Data | 13 martie 2020 17:17:10 | |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 100 |
Compilator | cpp-32 | Status | done |
Runda | Arhiva educationala | Marime | 0.65 kb |
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int a, b, c, d, x, y, t, i;
int cmmcdExtins(int a, int b, int& x, int& y)
{
if (!b)
{
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = cmmcdExtins(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
f >> t;
for (i = 1; i <= t; i++)
{
f >> a >> b >> c;
d = cmmcdExtins(a, b, x, y);
if (c % d)
g << "0 0" << "\n";
else
g << x * (c / d) << " " << y * (c / d) << "\n";
}
return 0;
}