Pagini recente » Cod sursa (job #3328764) | Cod sursa (job #3349976) | Cod sursa (job #2836060) | Cod sursa (job #3311477) | Cod sursa (job #3353034)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(long long a, long long b, long long &d, long long &x, long long &y){
if(b == 0){
d = a;
x = 1;
y = 0;
}
else{
long long x0,y0;
euclid(b, a%b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int n;
fin >> n;
while(n--){
long long a, b, c;
fin >> a >> b >> c;
long long d, x, y;
euclid(abs(a), abs(b), d, x, y);
if(c % d == 0){
x *= c / d;
y *= c / d;
if (a < 0)
x = -x;
if (b < 0)
y = -y;
fout << x << " " << y << '\n';
}
else{
fout << 0 << " " << 0 << '\n';
}
}
return 0;
}