Pagini recente » Cod sursa (job #1799930) | Cod sursa (job #1734657) | Cod sursa (job #1803636) | Cod sursa (job #2575186) | Cod sursa (job #3226024)
#include <bits/stdc++.h>
using namespace std;
ifstream in ("euclid3.in");
ofstream out ("euclid3.out");
int t;
int a,b,c;
int d;
void euclid(int a, int b, int & x, int & y)
{
if(b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
int x0, y0;
euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
ios_base :: sync_with_stdio(false);
in.tie(NULL);
in >> t;
while(t --)
{
in >> a >> b >> c;
int x = 0, y = 0;
euclid(a, b, x, y);
if(c % d)
{
out << 0 << " " << 0 << '\n';
}
else
{
out << 1ll * x * (c / d) << " " << 1ll * y * (c / d) << '\n';
}
}
return 0;
}