Pagini recente » Cod sursa (job #1447396) | Cod sursa (job #2883037) | Cod sursa (job #296299) | Cod sursa (job #211216) | Cod sursa (job #428788)
Cod sursa(job #428788)
/*
* File: main.cpp
* Author: SpeeDemon
*
* Created on March 29, 2010, 3:45 PM
*/
#include <cstdlib>
#include <fstream>
/*
*
*/
using namespace std;
inline int gcd( int a, int b, int& x, int& y )
{
if( !b )
{
x=1;
y=0;
return a;
}
int x0, y0, d=gcd( b, a%b, x0, y0 );
x=y0;
y=x0-a/b*y0;
return d;
}
int main( void )
{
int T, a, b, c, d, x, y;
ifstream in( "euclid3.in" );
ofstream out( "euclid3.out" );
in>>T;
for( ; T; --T )
{
in>>a>>b>>c;
d=gcd( a, b, x, y );
if( c%d )
out<<"0 0\n";
else c/=d, out<<(c*x)<<' '<<(c*y)<<'\n';
}
return EXIT_SUCCESS;
}