Cod sursa(job #1413601)

Utilizator VladuZ1338Vlad Vlad VladuZ1338 Data 1 aprilie 2015 23:09:08
Problema Invers modular Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.42 kb
#include <cstdio>
#include <cmath>

using namespace std;

int a, n, sol;

/*int pow (int x, int y)
{
    if (y==1) return x%n;
    else if (y%2==0) return pow ((x*x)%n, y/2)%n;
    else return (x * pow ((x*x)%n, y/2)%n)%n;
}*/

int main()
{
    freopen ("inversmodular.in", "r", stdin);
    freopen ("inversmodular.out", "w", stdout);
    scanf ("%d%d", &a, &n);
    sol=pow (a, n-2);
    printf ("%d", sol%n);
}