Pagini recente » Cod sursa (job #58708) | Cod sursa (job #551713) | Cod sursa (job #1245026) | Cod sursa (job #5453) | Cod sursa (job #1266257)
/*
* Code by Spiromanul
*/
#include <fstream>
const char IN [ ] = "euclid3.in" ;
const char OUT [ ] = "euclid3.out" ;
using namespace std;
ifstream fin ( IN ) ;
ofstream fout ( OUT ) ;
inline int extended_gcd ( int a , int b , int &xxx , int &yyy )
{
if ( not b ){
xxx = 1 ;
yyy = 0 ;
return a ;
}
int x0 , y0 ;
int D = extended_gcd ( b , a % b , x0 , y0 ) ;
xxx = y0 ;
int aux = a / b ;
yyy = x0 - aux * y0 ;
return D ;
}
int main ( )
{
int t ;
fin >> t ;
for ( ; t ; -- t )
{
int a , b , c ;
fin >> a >> b >> c ;
int x , y , d ;
d = extended_gcd ( a , b , x , y ) ;
if ( c % d )
fout << "0 0\n" ;
else fout << ( c / d ) * x << ' ' << ( c / d ) * y << '\n' ;
}
return 0;
}