Pagini recente » Cod sursa (job #1179779) | Cod sursa (job #1856215) | Cod sursa (job #2111041) | Cod sursa (job #2741335) | Cod sursa (job #2079100)
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int main( )
{
int T, a, aux, b, c, r;
fin >> T;
while( T-- ){
fin >> a >> b >> c;
int s_2 = 1, s_1 = 0, t_2 = 0, t_1 = 1;
if( b != 0 ){
while( a % b ){
r = a % b;
aux = s_2 - (a / b)* s_1;
s_2 = s_1;
s_1 = aux;
aux = t_2 - (a / b)* t_1;
t_2 = t_1;
t_1 = aux;
a = b;
b = r;
}
//cout << s_1 << " " << t_1 << "\n";
if(c % b) fout << 0 << " " << 0 << "\n";
else fout << s_1 * (c / b) << " " << t_1 * (c / b) << "\n";
}else cout << 1 << " " << 0;
}
}