Cod sursa(job #284798)
| Utilizator | Data | 21 martie 2009 23:07:06 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.67 kb |
#include <stdio.h>
int ee(int a,int b,int &x,int &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int d,x0,y0;
d = ee(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 a,b,c,d,x,y,t;
scanf("%d", &t);
while (t--)
{
scanf("%d%d%d", &a,&b,&c);
d = ee(a,b,x,y);
if (c%d)
printf("0 0\n");
else
printf("%d %d\n", x*(c/d),y*(c/d));
}
return 0;
}
