Pagini recente » Rating nick gurr (Schweppes) | Cod sursa (job #34410) | Cod sursa (job #1078292) | Cod sursa (job #3282101) | Cod sursa (job #459695)
Cod sursa(job #459695)
#include <cstdlib>
#include <fstream>
/*
*
*/
inline void gcd( int a, int b, int& d, int& x, int& y )
{
if( 0 == b )
{
x=1;
y=0;
d=a;
return;
}
int x0, y0;
gcd( b, a%b, d, x0, y0 );
x=y0;
y=x0-y0*a/b;
}
int main( void )
{
int N, a, b, c, d, x, y;
std::ifstream in( "euclid3.in" );
std::ofstream out( "euclid3.out" );
for( in>>N; N; --N )
{
in>>a>>b>>c;
gcd( a, b, d, x, y );
if( c%d )
out<<"0 0\n";
else c/=d, out<<(c*x)<<' '<<(c*y)<<'\n';
}
return EXIT_SUCCESS;
}