Cod sursa(job #3253669)

Utilizator daniela.ravoiuDumitrescu Daniela daniela.ravoiu Data 4 noiembrie 2024 09:55:20
Problema Invers modular Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>
# define LL long long
using namespace std;
LL a,b, d,x,y;
 void Euclid_Extins( LL a, LL b, LL&x, LL&y, LL&d)
 {
     if (b==0){d=a; x=1;y=0;}
     else { LL x0, y0;
     Euclid_Extins(b, a%b, x0, y0, d);
     x=y0;
     y=x0-a/b*y0;
     }
 }

int main()
{ifstream f("inversmodular.in") ;
ofstream g("inversmodular.out") ;
f>>a>>b;
Euclid_Extins(a,b,x,y,d);
if (x<=n) x+=n;
g<<x;

    return 0;
}