Pagini recente » Cod sursa (job #440851) | Cod sursa (job #991572) | Cod sursa (job #828562) | Cod sursa (job #1107879) | Cod sursa (job #3166148)
#include <iostream>
#include <fstream>
#define nl '\n'
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
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;
}
return;
}
void solve()
{
int a, b, c, x, y, d;
fin >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d != 0)
{
fout << 0 << ' ' << 0 << nl;
return;
}
x*=c/d;
y*=c/d;
fout << x << ' ' << y << nl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t;
fin >> t;
while (t--)
{
solve();
}
return 0;
}