Pagini recente » Cod sursa (job #1069547) | Cod sursa (job #422875) | Cod sursa (job #2726825) | Cod sursa (job #1823205) | Cod sursa (job #1898149)
#include <stdio.h>
#define InFile "euclid3.in"
#define OutFile "euclid3.out"
using namespace std;
FILE *fin, *fout;
void Euclid(int a, int b, int &d, long long &x, long long& y)
{
if (b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
long long x0, y0;
Euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
void Read()
{
int t, a, b, d, c;
long long x, y;
fscanf(fin, "%d", &t);
for (int i = 1; i <= t; i++)
{
fscanf(fin, "%d %d %d", &a, &b, &c);
Euclid(a, b, d, x, y);
if (c % d == 0)
{
x *= c / d;
y *= c / d;
fprintf(fout, "%lld %lld\n", x, y);
}
else
fprintf(fout, "%d %d\n", 0,0);
}
}
int main()
{
fin = fopen(InFile, "rt");
fout = fopen(OutFile, "wt");
Read();
fclose(fin); fclose(fout); return 0;
}