Pagini recente » Cod sursa (job #2954568) | Cod sursa (job #1062885) | Cod sursa (job #1915898) | Cod sursa (job #2073638) | Cod sursa (job #2334880)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
inline int Euclid(int a, int b, long long &x, long long &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
else {
long long x1, y1;
int d = Euclid(b, a % b, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
return d;
}
}
inline void Read() {
int N, x, y, c, d;
long long xx, yy;
fin >> N;
while (N--) {
fin >> x >> y >> c;
d = Euclid(x, y, xx, yy);
if (c % d != 0) {
fout << "0 0" << "\n";
continue;
}
fout << xx * c / d << " " << yy * c / d << "\n";
}
}
int main () {
Read();
fin.close(); fout.close(); return 0;
}