Pagini recente » Cod sursa (job #2296582) | Cod sursa (job #2850715) | Cod sursa (job #2383430) | Cod sursa (job #944469) | Cod sursa (job #2147318)
#include <fstream>
using namespace std;
ofstream fout("euclid3.out");
ifstream fin("euclid3.in");
void gcd(int a, int b, int &d, int &x, int &y){
if(b == 0){
d = a;
x = 1;
y = 0;
return;
}
gcd(b, a%b, d, x, y);
int aux = x;
x = y;
y = aux - (a/b)*y;
}
int main()
{
int n, a, b, c;
int d = 0;
int x = 0;
int y = 0;
fin >> n;
for(int i = 1; i <= n; i++){
fin >> a >> b >> c;
d = 0;
x = 0;
y = 0;
gcd(a, b, d, x, y);
if(c%d) {
fout << 0 << ' '<< 0<<'\n';
}
else{
fout << x * (c/d) << ' ' << y * (c/d) << '\n';
}
}
return 0;
}