Pagini recente » Cod sursa (job #1145128) | Cod sursa (job #352143) | Cod sursa (job #2922862) | Cod sursa (job #2068160) | Cod sursa (job #2720432)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t, x, y;
int gcd_extins(int a, int b)
{ if(!b)
{ x = 1;
y = 0;
return a;
}
int gcd = gcd_extins(b, a % b);
int x1 = y, y1 = x - y * (a / b);
x = x1;
y = y1;
return gcd;
}
int main()
{
fin >> t;
while(t--)
{ int a, b, c;
fin >> a >> b >> c;
x = y = 0;
int d = gcd_extins(a, b);
if(c % d != 0)
fout << 0 << ' ' << 0 << '\n';
else
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}