Pagini recente » Cod sursa (job #313808) | Cod sursa (job #3260816) | Cod sursa (job #3299152) | Cod sursa (job #3165032) | Cod sursa (job #478351)
Cod sursa(job #478351)
/*
* File: main.cpp
* Author: bitone
*
* Created on August 18, 2010, 11:01 AM
*/
#include <fstream>
#include <cstdlib>
using namespace std;
/*
*
*/
typedef signed int sint;
inline void gcd( sint a, sint b, sint& d, sint& x, sint& y )
{
if( !b )
{
x=1;
y=0;
d=a;
return;
}
sint x0, y0;
gcd( b, a%b, d, x0, y0 );
x=y0;
y=x0-(a/b)*y0;
}
int main( void )
{
int T, a, b, c, d, x, y;
ifstream in( "euclid3.in" );
ofstream out( "euclid3.out" );
for( in>>T; T; --T )
{
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;
}