Pagini recente » Cod sursa (job #548752) | Cod sursa (job #1665073) | Cod sursa (job #309934) | Cod sursa (job #1100196) | Cod sursa (job #2228042)
#include <bits/stdc++.h>
using namespace std;
void euclid_extins(long long a, long long b, long long &x, long long &y, long long &d){
if(b == 0){
x = 1;
y = 0;
d = a;
return ;
}
euclid_extins(b, a%b, x, y, d);
long long newx = y;
long long newy = x - y*(a/b) ;
x = newx;
y = newy;
}
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int main()
{
int n;
fin >> n;
for(int i = 1; i <= n; ++i){
long long a, b, c, x, y, d;
fin >> a >> b >> c;
euclid_extins(a, b, x, y, d);
if(c % d != 0)
fout << "0 0\n";
else fout << x * (c / d) << " " << y * (c / d) << '\n';
}
return 0;
}