Pagini recente » Cod sursa (job #173051) | Cod sursa (job #1271183) | Cod sursa (job #1273471) | Cod sursa (job #2129920) | Cod sursa (job #2458797)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0)
{
*x = 1;
*y = 0;
*d = a;
//cout << *d;
}
else
{
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main()
{
int a, b, c;
int t;
int x=0, y=0, d;
f >> t;
for (int i = 1; i <= t; i++)
{
f >> a >> b >> c;
euclid(a, b, &d, &x, &y);
//cout << "test";
if (c % d == 0) g << x * c / d << " " << y * c / d << endl;
else g << 0 << " " << 0 << endl;
}
}