Pagini recente » Statistici Sante Ciolos (SanteCiolos) | Cod sursa (job #2293939) | Cod sursa (job #2079829) | Cod sursa (job #1652328) | Cod sursa (job #1695072)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0)
{
*d = a;
*x = 1;
*y = 0;
}
else
{
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main()
{
int a, b, c;
int x, y;
int d;
int t;
fin >> t;
for(int i=1; i<=t; i++)
{
fin >> a >> b >> c;
euclid(a, b, &d, &x, &y);
if(c%d==0)
fout << x*(c/d) << " " << y*(c/d) << '\n';
else
fout << "0 0" << '\n';
}
return 0;
}