Pagini recente » Cod sursa (job #1361331) | Cod sursa (job #107056) | Cod sursa (job #1979852) | Cod sursa (job #1282102) | Cod sursa (job #1669086)
#include <fstream>
using namespace std;
int n,a,b,c,d,x,y;
int euclid(int a,int b, int &x,int &y){
if(b == 0){
x = 1;
y = 0;
return a;
}
int x0,y0;
d = euclid(b,a % b,x0,y0);
x = y0;
y = x0 - (a/b)*y0;
return d;
}
int main()
{
ifstream f("euclid3.in");
ofstream g("euclid3.out");
f >> n;
for(int count = 1; count <= n; ++count){
f >> a >> b >> c;
d = euclid(a,b,x,y);
if(c % d)
g << 0 <<' ' << 0 << '\n';
else
g << x * (c/d) << ' ' << y * (c/d) << '\n';
}
return 0;
}