Pagini recente » Cod sursa (job #946867) | Cod sursa (job #245111) | Cod sursa (job #1832547) | Cod sursa (job #2344694) | Cod sursa (job #2812994)
#include <bits/stdc++.h>
using namespace std;
int extended_euclid(int a,int b,int &x,int &y) {
if(b == 0) {
x = 1, y = 0;
return a;
}
int g = extended_euclid(b, a%b, x, y);
int aux = y;
y = x - (b * (a/b) ) * y;
x = aux;
return g;
}
void test_case() {
int a, b, c;
cin >> a >> b >> c;
int x, y;
int g = extended_euclid(a, b, x, y);
if( c % g > 0 ) cout << "0 0\n";
else {
cout << x * c/g << ' ' << y * c/g << '\n';
}
}
int main() {
int t;
cin >> t;
while(t--) {
test_case();
}
return 0;
}