Pagini recente » Cod sursa (job #2541367) | Cod sursa (job #1393251) | Cod sursa (job #1565017) | Cod sursa (job #1935788) | Cod sursa (job #1181360)
/*
Keep It Simple!
*/
#include<fstream>
using namespace std;
int cmmdc(int a,int b,int *x,int *y)
{
if(!b)
{
*x = 1;
*y = 0;
return a;
}
else
{
int d,x0,y0;
d = cmmdc(b,a%b,&x0,&y0);
*x = y0;
*y = x0 - (a/b)*y0;
return d;
}
}
int main()
{
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int T,x,y,c,d,a,b;
f >> T;
while(T--)
{
f >> a >> b >> c;
d = cmmdc(a,b,&x,&y);
if(c%d)
g << "0 0\n";
else
g << c/d*x << " " << c/d*y << "\n";
}
return 0;
}