Pagini recente » Cod sursa (job #1409351) | Cod sursa (job #368658) | Cod sursa (job #782882) | Cod sursa (job #2344406) | Cod sursa (job #3294815)
#include <iostream>
#include <fstream>
#include <cstdlib>
// #define mod 666013
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
unsigned long long i, j;
void euclid(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 x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
int main()
{
unsigned int T;
long long a, b, c, d, x, y;
fin >> T;
while (T > 0)
{
fin >> a >> b >> c;
euclid(a, b, &d, &x, &y);
if (c % d)
fout << "0 0" << endl;
else
fout << x * (c / d) << " " << y * (c / d) << endl;
T--;
}
return 0;
}