Pagini recente » Atasamentele paginii Clasament preoji2014_0_10 | Cod sursa (job #2217706) | Cod sursa (job #2217703) | Atasamentele paginii Clasament lot-2016-runda1 | Cod sursa (job #2217644)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int euclidExtended(int a, int b, int &x0, int &y0) {
if (!b) {
x0 = 1;
y0 = 0;
return a;
}
int x, y;
int cmmdc = euclidExtended(b, a % b, x, y);
x0 = y;
y0 = x - (a / b) * y;
return cmmdc;
}
int main() {
int T, a, b, c;
fin >> T;
while (T) {
fin >> a >> b >> c;
int x, y;
int cmmdc = euclidExtended(a, b, x, y);
if (c % cmmdc) {
fout << 0 << " " << 0 << "\n";
} else {
fout << x * (c / cmmdc) << " " << y * (c / cmmdc) << "\n";
}
T--;
}
}