Pagini recente » Cod sursa (job #1655743) | Cod sursa (job #1254914) | Cod sursa (job #21090) | Cod sursa (job #20011) | Cod sursa (job #2097137)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T;
void euclid(int a, int b, int &d, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
int x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
fin >> T;
int d, x, y, a, b, c;
for(int t = 1; t <= T; t++)
{
fin >> a >> b >> c;
euclid(a, b, d, x, y);
if(c % d == 0)
fout << 1LL * x * c / d << " " << 1LL * y * c / d;
else fout << 0 << " " << 0;
fout << '\n';
}
return 0;
}