Pagini recente » Cod sursa (job #1122654) | Cod sursa (job #2922722) | Cod sursa (job #1973229) | Cod sursa (job #1503222) | Cod sursa (job #1892737)
#include <iostream>
#include <cstdio>
using namespace std;
long int cmmdc(long int x, long int y)
{
if(y==0)
return x;
cmmdc(y, x % y);
}
void euclid_extins (long int x, long int y, long int &k, long int &l)
{
if(y==0)
{
k = 1;
l = 0;
}
else
{
long int k0,l0;
euclid_extins(y,x%y,k0,l0);
k=l0;
l=k0-l0*(x/y);
}
}
void read(long int &t, long int &x, long int&y, long int c)
{
scanf("%d", &t);
for(long int i=0; i<t; i++)
{
scanf("%d %d %d", &x, &y, &c);
long int k, l;
long int d = cmmdc(x,y);
euclid_extins (x, y, k, l);
if(c%d)
cout<<"0 0"<<endl;
else
cout<<k*(c/d)<<" "<<l*(c/d)<<endl;
}
}
int main()
{
freopen("euclid3.in", "r", stdin);
//freopen("euclid3.out", "w", stdout);
long int t, x, y, c;
read(t,x,y, c);
}