Cod sursa(job #2177455)
| Utilizator | Data | 18 martie 2018 16:53:10 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.7 kb |
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int cmmdc(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int d = cmmdc(b, a % b, x, y);
int aux = x;
x = y;
y = aux - (a / b) * y;
return d;
}
int main()
{
int t;
cin >> t;
while(t--)
{
int x, y, a, b, c;
cin >> a >> b >> c;
int d = cmmdc(a, b, x, y);
if(c % d != 0)
{
cout << "0 0\n";
}
else
{
cout << x * (c / d) << " " << y * (c / d) << "\n";
}
}
return 0;
}
