Pagini recente » Cod sursa (job #2815033) | Cod sursa (job #2048526) | Cod sursa (job #2053861) | Cod sursa (job #1656485) | Cod sursa (job #2008194)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int N;
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
} else {
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main()
{
fin >> N;
while( N-- )
{
int a, b, c;
fin >> a >> b >> c;
int x, y, d;
euclid( a, b, &d, &x, &y );
// cout << x << " " << y << " " << d << "\n";
fout << x * ( c / d ) << " " << y * ( c/ d ) << "\n";
}
return 0;
}