Pagini recente » Cod sursa (job #2343970) | Cod sursa (job #3214708) | Cod sursa (job #1073593) | Cod sursa (job #787132) | Cod sursa (job #398323)
Cod sursa(job #398323)
// Simionescu Andrei, 2/18/2010
// http://infoarena.ro/problema/euclid3
// Dificultate: EASY
// Categorii: -
#include <stdio.h>
int euclid( int a, int b, int * x, int * y ){
if ( b == 0 )
{
* x = 1;
* y = 0;
return a;
}
int x0, y0, d = euclid( 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 = euclid( a, b, &x, &y );
if( c % d )
printf( "0 0\n" );
else
printf( "%d %d\n", x * (c / d), y * (c / d) );
}
return 0;
}