Pagini recente » Cod sursa (job #1289828) | Cod sursa (job #1017637) | Cod sursa (job #691841) | Cod sursa (job #2034842) | Cod sursa (job #2152085)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
inline int Euclid(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
else {
int xx, yy, d;
d = Euclid(b, a % b, xx, yy);
x = yy;
y = xx - (a / b) * yy;
return d;
}
}
inline void Read() {
int T, a, b, c, x, y, d;
fin >> T;
while (T--) {
fin >> a >> b >> c;
d = Euclid(a, b, x, y);
if (c % d == 0) {
fout << x * (c / d) << " " << y * (c / d) << "\n";
}
else
fout << 0 << " " << 0 << "\n";
}
}
int main () {
Read();
fin.close(); fout.close(); return 0;
}