Cod sursa(job #1132959)

Utilizator DanutsDanut Rusu Danuts Data 4 martie 2014 10:32:16
Problema Invers modular Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.41 kb
#include<fstream>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
long long int a,n,d,x,y;
int euclid(long long int a,long long int b,long long int &d,long long int &x,long long &y){
	if(b==0){
		d=a;
		x=1;
		y=0;
	}
	else{
		long long int x0,y0;
		euclid(b,a%b,d,x0,y0);
		x=y0;
		y=x0-(a/b)*y0;
	}
}
int main (){
	f>>a>>n;
	euclid(a,n,d,x,y);
	g<<x*(1/d);
}