Pagini recente » Cod sursa (job #456931) | Statistici Martin Nicoleta (nicoleta_martin) | Cod sursa (job #1714606) | Cod sursa (job #3296575) | Cod sursa (job #2595995)
#include <iostream>
#include <fstream>
using namespace std;
void cmmdc(int a, int b, int *d, int *x, int *y)
{
if(a == 0)
{
*d = b;
*x = 0;
*y = 1;
return;
}
if(b == 0)
{
*d = a;
*x = 1;
*y = 0;
return;
}
int x0, y0;
cmmdc(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b)* y0;
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n, a, b, c, x, y, d;
fin >> n;
for(int i=1; i<=n; i++)
{
fin >> a >> b >> c;
cmmdc(a,b, &d, &x, &y);
if(c % d != 0)
{
fout << "0 0\n";
}
else
{
c /= d;
fout << x*c << " " << y*c << "\n";
}
}
return 0;
}