Pagini recente » Cod sursa (job #2648955) | Cod sursa (job #2787083) | Cod sursa (job #3185196) | Cod sursa (job #2589465) | Cod sursa (job #3041962)
#include <fstream>
using namespace std;
void euclid ( int a, int b, int &x, int &y, int &d ) {
if ( b == 0 ) {
d = a;
x = 1;
y = 0;
return;
}
int x0, y0;
euclid ( b, a % b, x0, y0, d );
x = y0;
y = x0 - ( a / b ) * y0;
}
ifstream fin ( "euclid3.in" );
ofstream fout ( "euclid3.out" );
int main() {
int t, a, b, c, d, x, y;
fin >> t;
while ( t-- ) {
fin >> a >> b >> c;
euclid ( a, b, x, y, d );
if ( c % d != 0 )
fout << "0 0\n";
else fout << c / d * x << ' ' << c / d * y << '\n';
}
return 0;
}