Pagini recente » Cod sursa (job #190257) | Cod sursa (job #2711549) | Cod sursa (job #1614449) | Cod sursa (job #237142) | Cod sursa (job #2578408)
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int T,a,b,c,d,x,y;
inline int gcd(int &x,int &y,int a,int b)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
int D=gcd(x,y,b,a%b);
int aux=x;
x=y;
y=aux-y*(a/b);
return D;
}
}
int main()
{
f>>T;
for(int t=1; t<=T; t++)
{
f>>a>>b>>c;
d=gcd(x,y,a,b);
if(c%d)
g<<0<<" "<<0<<"\n";
else
g<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
return 0;
}