Pagini recente » Cod sursa (job #2691303) | Cod sursa (job #878453) | Cod sursa (job #2364460) | Cod sursa (job #1268370) | Cod sursa (job #2868865)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
using ll = long long;
inline ll gcdEx(ll a, ll b, ll &x, ll &y){
if(b == 0){
x = 1, y = 0;
return a;
}
ll div = gcdEx(b, a % b, x, y);
ll x1 = y;
ll y1 = x - (a / b) * y;
x = x1, y = y1;
return div;
}
int main()
{
int t;
fin >> t;
while(t--){
ll a, b, c;
fin >> a >> b >> c;
ll x, y;
ll d = gcdEx(a, b, x, y);
if(c % d != 0)
fout << "0 0\n";
else fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}