Cod sursa(job #1463387)

Utilizator Tester01tester Tester01 Data 20 iulie 2015 20:39:18
Problema Algoritmul lui Euclid extins Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
long long t,a,b,x,y,c;

int _gcd_Extended(int a,int b){ 
	if (b==0) {
		x = 1;
		y = 0;
		return a;
	}
	int next = _gcd_Extended(b,a%b);
	long long aux = x;
	x = y;
	y = aux - (a/b)*y;
	return next;
}

int main(void) { 
 cin>>t;
 while(t--){
 	cin>>a>>b>>c;
 	int gcd = _gcd_Extended(a,b);
 	if (c%gcd==0){
 		cout<<x*c/gcd<<" "<<y*c/gcd<<"\n";
 	   } 
 	 else cout<<"0 0\n";
 }
 return 0;
}