Pagini recente » Cod sursa (job #195931) | Cod sursa (job #2324343) | Cod sursa (job #891982) | Cod sursa (job #2876384) | Cod sursa (job #1768857)
//
// main.cpp
// edu
//
// Created by Leonard Anusca on 01/10/2016.
// Copyright © 2016 Aaron. All rights reserved.
//
#include <fstream>
#include <iostream>
#include <assert.h>
using namespace std;
int n;
inline int GCD(int A,int B,int &X,int &Y);
int main() {
int a,b,c,d,x,y;
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
cin>>n;
for(int i = 1 ; i<=n ;i++){
cin>>a>>b>>c;
assert( -1000000000 <= a && a <= 1000000000 );
assert( -1000000000 <= b && b <= 1000000000 );
assert( -2000000000 <= c && c <= 2000000000 && c != 0 );
d = GCD( a, b, x, y );
if (c % d)
cout<<"0 0\n";
else
cout<<(x*(c/d))<<' '<<(y*(c/d))<<'\n';
}
return 0;
}
inline int GCD(int A,int B,int &X,int &Y){
if (B == 0)
{
X=1;
Y=0;
return A;
}
int X0,Y0,D;
D=GCD(B, A%B, X0, Y0);
X=Y0;
Y=X0 - (A/B) * Y0;
return D;
}