Pagini recente » Cod sursa (job #377531) | Cod sursa (job #1061085) | Cod sursa (job #3190553) | Cod sursa (job #1427740) | Cod sursa (job #971931)
Cod sursa(job #971931)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int T,i,a,b,c,z;
int euclid(int a, int b, long long &x, long long &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
long long x0,y0,d;
d=euclid(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;
long long x,y;
z=euclid(a,b,x,y);
if(c%z)
g << 0 << " " << 0 << '\n';
else
g << x*c/z << " " << y*c/z << '\n';
}
f.close();
g.close();
return 0;
}