Cod sursa(job #2034043)

Utilizator razvanboabesrazvan boabes razvanboabes Data 7 octombrie 2017 13:21:30
Problema Invers modular Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>

using namespace std;
ifstream in("inversmodular.in");
ofstream out("inversmodular.out");
long long xpow(long long b,long long exp,long long mod)
{
    long long ans=1;
    while(exp > 0)
    {
        if (e % 2)
            ans*=b%mod;
        b = b * b % mod;
        e /= 2;
    }
    return ans;
}
int main()
{
    int a,n,i,prod=1;
    in>>a>>n;
      out<<xpow(a,n-2,n);
    return 0;
}