Pagini recente » Cod sursa (job #626664) | Cod sursa (job #1307540) | Cod sursa (job #1194840) | Monitorul de evaluare | Cod sursa (job #428876)
Cod sursa(job #428876)
/*
* 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;
}