Pagini recente » Cod sursa (job #2980233) | Cod sursa (job #1071230) | Cod sursa (job #3225805) | Cod sursa (job #2195742) | Cod sursa (job #2877316)
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
const int NMAX = 1001;
int X[NMAX];
void EuclidExtins(int a, int b, int &d, int &x, int &y){
if(b == 0) {
x = 1;
y = 0;
d = a;
}else{
int x0, y0;
EuclidExtins(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main(){
int T, a, b, c, d, x, y, k;
in >> T;
while(T--) {
in >> a >> b >> c;
EuclidExtins(a, b, d, x, y);
if(c % d != 0)
out << "0 0\n";
else{
k = c / d;
x *= k;
y *= k;
out << x << ' ' << y << '\n';
}
}
return 0;
}