Cod sursa(job #148118)
| Utilizator | Data | 3 martie 2008 21:56:16 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include <stdio.h>
int T, d;
void cmmdc(int a, int b, int &x, int &y)
{
int x0, y0;
if ( b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
cmmdc(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int t, a, b, c, x, y;
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d", &T);
for ( t = 1; t <= T; t++)
{
scanf("%d %d %d", &a, &b, &c);
cmmdc(a, b, x, y);
if ( c % d !=0)
printf("0 0\n");
else
printf("%d %d\n", x * c / d, y * c / d );
}
}
