Pagini recente » Cod sursa (job #151187) | Cod sursa (job #117091) | Cod sursa (job #2862145) | Cod sursa (job #1910945) | Cod sursa (job #2912394)
#include <bits/stdc++.h>
using namespace std;
struct hatz {
int x, y;
};
int srcval;
hatz euclid_extins(int a, int b) {
if (b == 0) {
/// ajung la ecuatia a * x = srcval
if (srcval % a == 0)
return {srcval / a, 0};
return {0, 0};
}
int x, y;
hatz valxy0 = euclid_extins(b, a % b);
x = valxy0.y;
y = valxy0.x - (a / b) * valxy0.y;
return {x, y};
}
int main() {
ifstream cin ("euclid3.in");
ofstream cout ("euclid3.out");
int t, a, b;
cin >> t;
while (t--) {
cin >> a >> b >> srcval;
hatz sol = euclid_extins(a, b);
cout << sol.x << " " << sol.y << "\n";
}
return 0;
}