Pagini recente » Cod sursa (job #1101175) | Cod sursa (job #1894348) | Cod sursa (job #1775384) | Cod sursa (job #2448835) | Cod sursa (job #1991251)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int euclid(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
else
{
int x0, y0, d;
d = euclid(b, a%b, x0, y0);
x = y0;
y = x0 - a/b * y0;
return d;
}
}
int main()
{
int t;
f >> t;
while(t)
{
int a, b, c, d, x, y;
f >> a >> b >> c;
d = euclid(a, b, x, y);
if(c % d == 0) g<< c/d * x << " " << c/d*y << "\n";
else g<< "0 0\n";
t--;
}
return 0;
}