Pagini recente » Cod sursa (job #1971447) | Cod sursa (job #3221280) | Cod sursa (job #2978529) | Cod sursa (job #559693) | Cod sursa (job #2401382)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(long long a, long long b, long long &d, long long &x, long long &y)
{
if(!b)
{
d=a;
x=1;
y=0;
}
else
{
long long x0, y0;
euclid(b, a%b, d, x0, y0);
x=y0;
y=x0-a/b*y0;
}
}
int main()
{
long long t, a, b, c;
fin>>t;
while(t--)
{
fin>>a>>b>>c;
long long x, y, d;
euclid(a, b, d, x, y);
if(c%d)
{
fout<<"0 0\n";
}
else
{
fout<<x*c/d<<' '<<y*c/d<<'\n';
}
}
return 0;
}