Cod sursa(job #1463390)

Utilizator Tester01tester Tester01 Data 20 iulie 2015 20:46:26
Problema Invers modular Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <fstream>
using namespace std;
ifstream cin("inversmodular.in");
ofstream cout("inversmodular.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>>a>>b;
 _gcd_Extended(a,b);
 if (x<0) cout<<x+b;
     else cout<<x;
 return 0;
}