Pagini recente » Cod sursa (job #2639148) | Cod sursa (job #1460256) | Cod sursa (job #2683237) | Cod sursa (job #545678) | Cod sursa (job #1204861)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
int Bomb(int a,int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int xx, yy;
int d = Bomb(b, a % b, xx, yy);
x = yy;
y = xx - (a / b) * yy;
return d;
}
int main() {
int a,b,c,x,y,d,i;
fin >> t;
while(t--){
fin >> a >> b >> c;
d = Bomb(a, b, x, y);
cout << d <<" ";
if (c % d)
fout << "0 0\n";
else
fout << x * (c / d) << " " << y * (c / d) << "\n";
}
fin.close();
fout.close();
return 0;
}