Pagini recente » Autentificare | Diferente pentru runda/vot/voteaza_nargy_si_fumeanu intre reviziile 2 si 3 | Cod sursa (job #3286763) | Cod sursa (job #1686789) | Cod sursa (job #151034)
Cod sursa(job #151034)
#include <stdio.h>
using namespace std;
long gcd(long a,long b,long &x,long &y)
{
if (!b)
{
x=1;
y=0;
return a;
}
long x0,y0,d;
d=gcd(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
int main()
{
freopen("euclid3.in","r",stdin);
freopen("euclid3.out","w",stdout);
int t,i;
long a,b,c,x,y;
scanf("%d\n",&t);
for (i=0;i<t;i++)
{
scanf("%ld %ld %ld\n",&a,&b,&c);
long d;
d=gcd(a,b,x,y);
if (c%d)
printf("0 0\n");
else
printf("%ld %ld\n",x*(c/d),y*(c/d));
}
return 0;
}