Pagini recente » Cod sursa (job #376432) | Cod sursa (job #2896695) | Cod sursa (job #2797302) | Cod sursa (job #693049) | Cod sursa (job #2725337)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
void euclid(int a , int b, int &d, int &x ,int &y) {
if(b == 0) {
d = a;
x = 1, y = 1;
} else {
int x1 , y1;
euclid(b, a % b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int main()
{
int n; fin >> n;
for(int i = 1; i <= n; ++i) {
int x = 0, y = 0, d = 0;
int a, b, c; fin >> a >> b >> c;
euclid(a, b, d, x, y);
if(c % d == 0)
fout << x * (c / d) << " " << y * (c / d) << '\n';
else
fout << "0 0\n";
}
return 0;
}