Cod sursa(job #3194852)

Utilizator AlexSerban21Serban Alexandru AlexSerban21 Data 19 ianuarie 2024 16:26:49
Problema Invers modular Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include <fstream>
using namespace std;
ifstream fin ("inversmodular.in");
ofstream fout ("inversmodular.out");
long long x,y,x0,y0,a,n;
void euclid_extins (long long a,long long b)
{
    if (b==0)
    {
        x=x0=1;
        y=y0=0;
    }
    else
    {
        euclid_extins (b,a%b);
        x=y0;
        y=x0-(a/b)*y0;
        x0=x;
        y0=y;
    }
}
int main ()
{
    fin>>a>>n;
    euclid_extins (a,n);
    fout<<x;
    return 0;
}