Pagini recente » Cod sursa (job #315607) | Cod sursa (job #316224) | Cod sursa (job #737104) | Cod sursa (job #2753701) | Cod sursa (job #1991250)
#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;
}