Pagini recente » tema | Cod sursa (job #2599878) | Cod sursa (job #41902) | Cod sursa (job #2385267) | Cod sursa (job #459333)
Cod sursa(job #459333)
#include <cstdlib>
#include <fstream>
/*
*
*/
using namespace std;
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-(a/b)*y0;
}
int main( void )
{
int N, a, b, c, d, x, y;
ifstream in( "euclid3.in" );
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";
else c/=d, out<<c*x<<' '<<c*y;
out<<'\n';
}
return 0;
}