Pagini recente » Cod sursa (job #1558457) | Cod sursa (job #2900216) | Cod sursa (job #402311) | Cod sursa (job #349994) | Cod sursa (job #2692526)
#include <bits/stdc++.h>
std::ifstream in("euclid3.in");
std::ofstream out("euclid3.out");
int euclid_extins(int a,int b,int &x,int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
else
{
int x0,y0;
int d = euclid_extins(b,a%b,x0,y0);
x = y0;
y = x0 - (a/b)*y0;
return d;
}
}
int main()
{
int n;
in >> n;
for(;n;n--)
{
int a,b,c;
int x = 0 , y = 0;
in >> a >> b >> c;
int d = euclid_extins(a,b,x,y);
int k = c/d;
if(c % d)
{
out << "0 0\n";
}
else
out << k * x << ' ' << k * y << '\n';
}
in.close();
out.close();
return 0;
}