Cod sursa(job #3296352)

Utilizator iordacheMatei Iordache iordache Data 12 mai 2025 12:16:26
Problema Invers modular Scor 60
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>
#define pb push_back
//#define int long long
using namespace std;
const int N=1e5+5;int mod;
int binpow(int n, int e)
{
    int ans=1;
    while(e)
    {
        if(e&1) ans=1ll*ans*n%mod;
        n=1ll*n*n%mod;
        e>>=1;
    }
    return ans;
}
int inv(int x) {return binpow(x,mod-2);}
signed main()
{
    ifstream cin("inversmodular.in");ofstream cout("inversmodular.out");
    int n;
    cin>>n>>mod;
    cout<<inv(n);
}