Cod sursa(job #2323634)

Utilizator TeodorAxinteAxinte Teodor TeodorAxinte Data 19 ianuarie 2019 14:24:34
Problema Invers modular Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.34 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
typedef long long Int;
Int a,n;
Int putere(Int b,Int e)
{
    if(e==0)return 1;
    Int r=putere(b,e/2);
    r=r*r%n;
    if(e%2)r=r*b%n;
    return r;
}
int main()
{
    f>>a>>n;
    g<<putere(a,n-2);
    return 0;
}