Pagini recente » Votati personajul preferat Infoarena | Cod sursa (job #1181446) | Cod sursa (job #573206) | Cod sursa (job #1696031) | Cod sursa (job #1436740)
using namespace std;
#include <fstream>
ifstream f ("euclid3.in");
ofstream g ("euclid3.out");
int gcd (int a, int b, int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
int x0,y0,d;
d=gcd(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
int main ()
{
int t,a,b,c,d,x,y;
f>>t;
while(t--)
{
f>>a>>b>>c;
d=gcd(a,b,x,y);
if (c%d) g<<"0 0"<<'\n';
else g<<x*c/d<<' '<<y*c/d<<'\n';
}
return 0;
}