Pagini recente » Cod sursa (job #2455011) | Cod sursa (job #2050227) | Cod sursa (job #1937980) | Cod sursa (job #1785608) | Cod sursa (job #2259526)
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int a, int b, int &x, int &y)
{
if(b==0)
{
x = 1;
y = 0;
return a;
}
int d = cmmdc(b, a%b, x, y);
int xnou = y;
y = x - y*(a/b);
x = xnou;
return d;
}
int main()
{
ifstream fcin("euclid3.in");
ofstream fcout("eculid3.out");
int n;
fcin>>n;
for (int i=1; i<=n; i++)
{
int a, c, b, x, y;
fcin>>a>>b>>c;
cmmdc(a, b, x, y);
if(c%d==0)
{
x = x * (c/d);
y = y * (c/d);
}
else{
x=y=0;
}
fcout<<x<< " " << y << '\n';
}
return 0;
}