Pagini recente » Cod sursa (job #2144508) | Cod sursa (job #3207112) | Cod sursa (job #842931) | Cod sursa (job #11589) | Cod sursa (job #3156350)
#include <algorithm>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
using namespace std;
#define pii pair <int, int>
string filename = "euclid3";
#ifdef LOCAL
ifstream fin("input.in");
ofstream fout("output.out");
#else
ifstream fin(filename + ".in");
ofstream fout(filename + ".out");
#endif
void euclid(int a, int b, int &x, int &y, int &d){
if(b == 0){
d = a;
x = 1, y = 0;
return;
}
euclid(b, a % b, x, y, d);
int x0 = x, y0 = y;
x = y0;
y = x0 - (a / b) * y0;
}
void solve(){
int a, b, c;
fin >> a >> b >> c;
int x = 0, y = 0, d = 0;
euclid(a, b, x, y, d);
if(c % d == 0){
x *= (c / d);
y *= (c / d);
fout << x << ' ' << y << '\n';
}else{
fout << 0 << ' ' << 0 << '\n';
}
}
signed main(){
int T;
fin >> T;
while(T--){
solve();
}
return 0;
}