Pagini recente » Cod sursa (job #1030909) | Cod sursa (job #2960410) | Cod sursa (job #1686001) | Cod sursa (job #565034) | Cod sursa (job #445998)
Cod sursa(job #445998)
/*
* File: main.cpp
* Author: virtualdemon
*
* Created on April 24, 2010, 3:11 PM
*/
#include <cstdlib>
#include <fstream>
/*
*
*/
using namespace std;
inline void gcd( int a, int b, int& x, int& y, int& d )
{
if( !b )
{
d=a;
x=1;
y=0;
return;
}
int aux;
gcd( b, a%b, x, y, d );
aux=x;
x=y;
y=aux-(a/b)*y;
}
int main(int argc, char** argv)
{
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, x, y, d );
if( c%d )
out<<"0 0\n";
else c/=d, out<<(x*c)<<' '<<(c*y)<<'\n';
}
return (EXIT_SUCCESS);
}