Pagini recente » Cod sursa (job #2524713) | Cod sursa (job #1317613) | Rating George Dumitrescu (dumitrescugeorge) | Cod sursa (job #1455125) | Cod sursa (job #3179406)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
void cmmdc (long long a, long long b, long long &d, long long &x, long long &y)
{
if (b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
long long x1, y1;
cmmdc(b, a % b, d, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
}
}
int main()
{
int n;
long long a, b, c;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a >> b >> c;
long long d, x, y;
cmmdc(a, b, d, x, y);
if (c % d != 0)
cout << 0 << " " << 0 << endl;
else
cout << x * (c / d) << " " << y * (c / d) << endl;
}
return 0;
}