Pagini recente » Cod sursa (job #2503434) | Cod sursa (job #1781602) | Cod sursa (job #952361) | Cod sursa (job #1868658) | Cod sursa (job #3214834)
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int Q, a, b, c, x, y, d;
void mod_inv(int a, int b, int &d, int &x, int &y){
if(b == 0)
x = 1, y = 1, d = a;
else {
int x1, y1;
mod_inv(b, a % b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
}
int32_t main(){
fin >> Q;
while(Q--){
fin >> a >> b >> c;
mod_inv(a, b, d, x, y);
if(c % d)
fout << "0 0\n";
else fout << (x * c) / d << " " << (y * c) / d << "\n";
}
}