Pagini recente » Cod sursa (job #2953615) | Cod sursa (job #2872476)
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define forn(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(a) (int)a.size()
#define int long long
int euclid(int a, int b, int *x, int *y) {
if(b == 0) {
*x = 1;
*y = 0;
return a;
}
int x1, y1;
int gg = euclid(b, a % b, &x1, &y1);
*x = y1;
*y = x1 - (a / b) * y1;
return gg;
}
void solve() {
int a, b, c;
cin >> a >> b >> c;
int x, y, g;
g = euclid(a, b, &x, &y);
if(c % g != 0) {
cout << "0 0\n";
} else {
cout << x * c / g << " " << y * c / g << "\n";
}
}
int32_t main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int t = 1;
cin >> t;
while(t--) {
solve();
}
}