Pagini recente » Cod sursa (job #971771) | Cod sursa (job #1169397) | Cod sursa (job #2608196) | Cod sursa (job #2609059) | Cod sursa (job #1991249)
#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;
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;
}