Pagini recente » Cod sursa (job #2258652) | Cod sursa (job #560638) | Cod sursa (job #1321894) | Cod sursa (job #1872883) | Cod sursa (job #2550198)
#include<fstream>
#define ll long long
using namespace std;
ll a,b,c,x,y,ca,n;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
void gcd_extended(ll a, ll b, ll&x, ll&y){
if(!b)
x=1, y=0,ca=a;
else{
ll x0, y0;
gcd_extended(b, a%b, x0, y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main(){
cin>>n;
while(n--){
cin>>a>>b>>c;
gcd_extended(a,b,x,y);
if(c%ca==0){
cout<<1ll*x*c/ca<<' '<<1ll*y*c/ca<<'\n';
} else cout<<"0 0\n";
}
return 0;
}