Pagini recente » Cod sursa (job #140344) | Cod sursa (job #3186226) | Cod sursa (job #2454311) | Cod sursa (job #2157400) | Cod sursa (job #2289446)
#include <iostream>
#define nl '\n'
using namespace std;
int cmmdc(int a,int b,int &x, int &y) {
if(!b){
x=1;
y = 0;
return a;
}
else{
int x0,y0,c,d;
d = cmmdc(b,a%b,x0,y0);
c = a/b;
x = y0;
y = x0 - c * y0;
return d;
}
}
int main() {
int n;
cin >> n;
for(int i=0;i<n;++i){
int a,b,d,x,y;
cin >> a >> b >> d;
int c = cmmdc(a,b,x,y);
///cout << c << nl;
if(d%c) cout << 0 << ' ' << 0 << nl;
else {
c = d/c;
cout << x*c << ' ' << y*c << nl;
}
}
return 0;
}