Pagini recente » Cod sursa (job #859813) | Cod sursa (job #2477202) | Cod sursa (job #2305239) | Cod sursa (job #2808442) | Cod sursa (job #2480267)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void Euclid(int a, int b, int &x, int &y)
{
int aux;
if(b == 0)
{
x = 1;
y = 0;
return;
}
else
{
Euclid(b, a%b, x, y);
aux = x;
x = y;
y = aux - a/b*y;
}
}
int main()
{
int T, a ,b ,c, d;
fin >> T;
while(T--)
{
fin >> a >> b >> c;
d = __gcd(a, b);
if(c % d != 0)
{
fout << "0 0\n";
continue;
}
int x = 0, y = 0;
Euclid(a, b, x, y);
fout << x*(c/d) << ' ' << y*(c/d) << '\n';
}
return 0;
}