Pagini recente » Cod sursa (job #1287956) | Cod sursa (job #135964) | Diferente pentru home intre reviziile 207 si 208 | Monitorul de evaluare | Cod sursa (job #1034265)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
short t;
int a, b, c, d, x, y;
int euclid(int a, int b, int &x, int &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
int x0, y0, d;
d=euclid(b, a%b, x0, y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
int main()
{
for(cin>>t; t; t--)
{
cin>>a>>b>>c;
d=euclid(a, b, x, y);
if(c%d) cout<<"0 0"<<'\n';
else cout<<x*(c/d)<<" "<<y*(c/d)<<'\n';
}
return 0;
}