Pagini recente » Cod sursa (job #2490459) | Cod sursa (job #2938000) | Cod sursa (job #2881518) | Cod sursa (job #1320598) | Cod sursa (job #3244227)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long t,i,a,b,c,d,x,y;
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=1;
}
else
{
long long x1,y1;
euclid(b,a%b,d,x1,y1);
x=y1;
y=x1-a/b*y1;
}
}
int main()
{
fin>>t;
for(i=1;i<=t;i++)
{
fin>>a>>b>>c;
euclid(a,b,d,x,y);
if(c%d)fout<<0<<" "<<0<<'\n';
else
{
long long n=c/d;
fout<<n*x<<" "<<n*y<<'\n';
}
}
return 0;
}