Pagini recente » Cod sursa (job #2472226) | Cod sursa (job #167073) | Cod sursa (job #2711756) | Cod sursa (job #612624) | Cod sursa (job #2195081)
#include <fstream>
#include <algorithm>
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==0)
{
*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;
fin>>t;
for(long long nr_t=1;nr_t<=t;nr_t++)
{
long long a,b,c;
fin>>a>>b>>c;
long long d,x,y;
euclid(a,b,&d,&x,&y);
if(c%d!=0)
{
fout<<"0 0\n";
continue;
}
long long f=c/d;
fout<<f*x<<" "<<f*y<<"\n";
}
return 0;
}