Pagini recente » Cod sursa (job #3186350) | Cod sursa (job #590783) | Cod sursa (job #2195976) | Cod sursa (job #440142) | Cod sursa (job #1589184)
# 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;
}