Pagini recente » Cod sursa (job #963049) | Cod sursa (job #846872) | Cod sursa (job #2289504) | Cod sursa (job #52431) | Cod sursa (job #1755102)
//============================================================================
// Name : euclid3.cpp
// Author : Margineanu Cristian
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int x, y, d;
void extendedEuclid(int a, int b){
if (b == 0){
x = 1;
y = 0;
d = a;
return;
}
extendedEuclid(b, a%b);
int x1 = y;
int y1 = x - (a / b) * y;
x = x1;
y = y1;
}
int main() {
int t, a, b, c;
fin >> t;
for (int i = 1; i <= t; i++){
fin >> a >> b >> c;
extendedEuclid(a, b);
if (c%d == 0){
d = c / d;
fout << x * d << ' ' << y * d << '\n';
}
else
fout << "0 0\n";
}
fin.close();
fout.close();
return 0;
}