Pagini recente » Cod sursa (job #994784) | Statistici Danila Sebastian (UTCN_DANILA_SEBASTIAN) | Cod sursa (job #1012869) | fmi-no-stress-9-warmup/solutii | Cod sursa (job #2000539)
#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 (ceil((double)c / a) - (int) c/a > 0)
{
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;
}