Pagini recente » Cod sursa (job #2975910) | Cod sursa (job #413581) | Cod sursa (job #2118651) | Cod sursa (job #3125349) | Cod sursa (job #2559367)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ( "euclid3.in" );
ofstream fout ( "euclid3.out" );
int t;
int a, b, x, y, c;
void euclid_extins ( int a, int b, int&x, int&y ) {
if ( b == 0 ) {
x = 1;
y = 0;
return;
}
int x0, y0;
euclid_extins ( b, a % b, x0, y0 );
x = y0;
y = x0 - y0 * ( a / b );
}
int main() {
fin >> t;
while ( t-- ) {
fin >> a >> b >> c;
int d = __gcd ( a, b );
if ( c % d != 0 ) {
fout << 0 << ' ' << 0 << '\n';
continue;
}
int x, y;
euclid_extins ( a, b, x, y );
fout << x* ( c / d ) << ' ' << y* ( c / d ) << '\n';
}
return 0;
}