Pagini recente » Cod sursa (job #488891) | Cod sursa (job #291443) | Cod sursa (job #1973467) | Cod sursa (job #1029331) | Cod sursa (job #2000541)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid3(int a, int &x, int b, int &y, int c)
{
if (b == 0)
{
if (c % a)
{
x = 0;
y = 0;
return;
}
x = c / a;
y = 0;
}
else
{
int x0, y0;
euclid3(b, x0, a % b, y0, c);
x = y0;
y = x0 - a / b * y0;
}
}
int main()
{
int T, a, b, c, x, y;
fin >> T;
while (T--)
{
fin >> a >> b >> c;
euclid3(a, x, b, y, c);
fout << x << " " << y << "\n";
}
return 0;
}