Cod sursa(job #2748454)

Utilizator TeogeoIacobTeofil Iacob TeogeoIacob Data 30 aprilie 2021 19:19:04
Problema Invers modular Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.39 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int a,x,y,n;
void cmmdc(int a,int b, int &x,int &y)
{
    if(b==0)
    {
        x=1;
        y=0;
        return ;
    }
    int X,Y;
    cmmdc(b,a%b,X,Y);
    x=Y;
    y=X-a/b*Y;
}

int main()
{
    f>>a>>n;
    cmmdc(a,n,x,y);
    g<<x;

    return 0;
}