Cod sursa(job #1514859)

Utilizator andreiudilaUdila Andrei andreiudila Data 31 octombrie 2015 18:49:42
Problema Invers modular Scor 50
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <fstream>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");

long long a,b,x,y,d,t,i,c,n;

void euclid_ext (long long a, long long b, long long &x, long long &y)
{
    if(b==0) { x=1; y=0;}
    else{

    long long xp=0, yp=0;

    euclid_ext(b, a%b, xp, yp);

    x=yp;
    y=xp-(a/b)*yp;

    }
}

int main()
{

    fin>>a>>n;

    euclid_ext(a, n, x, y);

    fout<<x;


    return 0;
}