Pagini recente » Cod sursa (job #1385984) | Cod sursa (job #1343048) | Cod sursa (job #877531) | Cod sursa (job #1520264) | Cod sursa (job #2017763)
#include <fstream>
using namespace std;
ifstream fin ("Euclid3.in");
ofstream fout ("Euclid3.out");
int a, b, c, t;
int eGCD (int a, int b, int &x, int &y)
{
if ( b == 0 )
{
x = 1;
y = 0;
return a;
}
else
{
int x0 = 0, y0 = 0;
int d = eGCD (b, a%b, x0, y0);
x = y0;
y = x0 - (a/b) * y0;
return d;
}
}
int main()
{
fin>>t;
while (t--)
{
fin>>a>>b>>c;
int x = 0, y = 0;
int d = eGCD(a, b, x, y);
if ( c % d )
fout<<"0 0"<<'\n';
else
fout<< x * (c/d) <<" "<< y * (c/d) <<" "<<'\n';
}
}