Pagini recente » Cod sursa (job #196341) | Cod sursa (job #1778405) | Cod sursa (job #735516) | Cod sursa (job #2059747) | Cod sursa (job #2771069)
#include <iostream>
#include <fstream>
#include <deque>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
///const int NMAX = 1e3;
const int INF = 1e9;
void euclid( long long a, long long b, long long& x, long long& y, long long& d ) {
if ( b == 0 ) {
d = a;
x = 1;
y = 0;
} else {
long long x0, y0;
euclid( b, a % b, x0, y0, d );
x = y0;
y = x0 - ( a / b ) * y0;
}
}
int main() {
ifstream fin( "euclid3.in" );
ofstream fout( "euclid3.out" );
int n, i, a, b, c;
long long x, y, d;
fin >> n;
for ( i = 0; i < n; i ++ ) {
fin >> a >> b >> c;
d = x = y = 0;
euclid( a, b, x, y, d );
if ( c % d != 0 ) {
fout << "0 0\n";
} else {
fout << x * c / d << ' ' << y * c / d << '\n';
}
}
return 0;
}