Pagini recente » Cod sursa (job #1722545) | Cod sursa (job #456783) | Cod sursa (job #2713640) | Cod sursa (job #1814097) | Cod sursa (job #3184564)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
long long euclid_extins(long long a, long long b, long long& x, long long& y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
long long x1,y1;
int d=euclid_extins(b,a%b,x1,y1);
x=y1;
y=x1-y1*(a/b);
return d;
}
}
long long n,a,b,c,d,xA,yA;
int main()
{
f>>n;
for(int i=1; i<=n; i++)
{f>>a>>b>>c;
d=euclid_extins(a,b, xA, yA);
if(c%d==0)
{
g<<xA*(c/d)<<' '<<yA*(c/d)<<'\n';
}
else g<<"0 0"<<'\n';
}
return 0;
}