Pagini recente » Cod sursa (job #3135065) | Cod sursa (job #1488619) | Cod sursa (job #3258471) | Cod sursa (job #3290886) | Cod sursa (job #2494651)
#include <fstream>
using namespace std;
ifstream in ("euclid3.in");
ofstream out ("euclid3.out");
void extins(long long a,long long b,long long &d,long long &x,long long &y)
{
if(b==0)
{
x=1;
y=0;
d=a;
}
else
{
long long x0,y0;
extins(b,a%b,d,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
long long t,tt;
in>>t;
long long a,b,c;
long long x,y,d;
for(tt=1;tt<=t;tt++)
{
in>>a>>b>>c;
x=y=d=0;
extins(a,b,d,x,y);
if(c%d)
out<<"0 0";
else out<<x*c/d<<' '<<y*c/d;
out<<'\n';
}
return 0;
}