Pagini recente » Cod sursa (job #828457) | Cod sursa (job #214562) | Cod sursa (job #2268320) | Cod sursa (job #1608220) | Cod sursa (job #1943438)
#include <iostream>
#include <fstream>
#include <limits.h>
using namespace std;
int euclid(int a, int b, int &x, int &y)
{
if (b == 0){
x = 1;
y = 0;
return a;
}
else{
int x0,y0,c;
c = euclid(b,a%b,x0,y0);
x = y0;
y = x0 - (a/b)*y0;
return c;
}
}
int main()
{
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int t;
int a,b,c,aux;
int x,y;
f>>t;
for(int i=0;i<t;++i){
in>>a>>b>>c;
aux = euclid(a,b,x,y);
if (c % aux)
out << "0 0"<<'\n';
else
out << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}