Pagini recente » Cod sursa (job #2170381) | Cod sursa (job #267162) | Cod sursa (job #2170369) | Cod sursa (job #982279) | Cod sursa (job #2432277)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int gcd(int a,int b)
{
if (b==0) return a;
else return gcd(b,a%b);
}
void gcdext(int a,int b,int &x,int &y)
{
int x0,y0;
if (b==0)
{
x=1;
y=0;
}
else
{
gcdext(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
int a,b,c,x,y,d;
cin >> a >> b >> c;
d=gcd(a,b);
gcdext(a,b,x,y);
if (d==1) cout << "0 0";
else cout << c/d*x << " " << c/d*y;
}