Pagini recente » Cod sursa (job #2338119) | Cod sursa (job #1182618) | Cod sursa (job #1676496) | Cod sursa (job #2708313) | Cod sursa (job #1589186)
# include <fstream>
# include <algorithm>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int a,b,c,d,x,y,T;
int euclid (int a, int b, int &x, int &y) {
if (b==0) {
x=1; y=0;
return a;
}
int D, x0, y0;
D=euclid (b, a%b, x0, y0);
x=y0;
y=x0 - (a/b)*y0;
return D;
}
int main ()
{
f>>T;
for (int t=1; t<=T; ++t) {
f>>a>>b>>c;
d=euclid (a, b, x, y);
if (c%d==0) g<<x*(c/d)<<" "<<y*(c/d)<<"\n";
else g<<"0 0\n";
}
return 0;
}