Cod sursa(job #2950929)
Utilizator | Data | 4 decembrie 2022 20:54:46 | |
---|---|---|---|
Problema | Invers modular | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include<fstream>
using namespace std;
ifstream F("inversmodular.in");
ofstream G("inversmodular.out");
int a,b,x,y,c,d,e,f,g,h;
int main()
{
for(F>>a>>b,c=b,x=1;b;d=a,e=b,a=e,b=d%e,f=d/e,g=x,h=y,x=h,y=g-f*h);
for(;x<0;x+=c);
return G<<x,0;
}