Pagini recente » Cod sursa (job #675247) | Cod sursa (job #2624329) | Cod sursa (job #2624140) | Cod sursa (job #1568661) | Cod sursa (job #2873533)
#include <bits/stdc++.h>
#define LL long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
pair<LL, LL> euclid(LL a, LL b) {
if (b == 0)
return {1, 0};
auto p = euclid(b, a % b);
return {p.second, p.first - (a / b) * p.second};
}
int main() {
int t;
fin >> t;
for (int i = 0; i < t; i++) {
LL a, b, c;
fin >> a >> b >> c;
auto res = euclid(a, b);
if (res.second % res.first)
fout << 0 << ' ' << 0 << '\n';
else
fout << res.first << ' ' << res.second << '\n';
}
return 0;
}