Cod sursa(job #2236158)

Utilizator teodorgTeodor G teodorg Data 28 august 2018 13:45:53
Problema Invers modular Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.35 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int a,n,m,e,p;
int putere(int e)
{
    if(e==0)
        return 1;
    int r=putere(e/2);
    r=1LL*r*r%m;
    if(e%2==1)
        r=1LL*r*a%m;
    return r;
}
int main()
{
    f>>a>>n;
    g<<putere(n-2);
    return 0;
}