Pagini recente » Cod sursa (job #2753938) | Cod sursa (job #2487441) | Cod sursa (job #1770069) | Cod sursa (job #2614964) | Cod sursa (job #2140911)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("euclid3.in") ;
ofstream fout("euclid3.out") ;
int gcd(int a,int b,int *x,int *y)
{
int rez;
if ( a == 0 )
{
*x = 1 ;
*y = 1 ;
return b;
}
int x1 , y1 ;
rez = gcd(b%a,a,&x1,&y1) ;
*x = y1-(b/a)*x1;
*y = x1 ;
return rez;
}
int main()
{
int i , a , n , b , c , cmmdc;
int xx , yy ;
fin >> n ;
for ( i = 1 ; i <= n ; i++ )
{
fin >> a >> b >> c ;
cmmdc = gcd(a,b,&xx,&yy) ;
if ( c%cmmdc == 0 )
fout << xx*(c/cmmdc) << " " << yy*(c/cmmdc) << '\n' ;
else
fout << "0 " << "0" << '\n' ;
}
}