Cod sursa(job #2742847)

Utilizator michael_blazemihai mihai michael_blaze Data 22 aprilie 2021 00:04:10
Problema Invers modular Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <fstream>

std :: ifstream fin("lgput.in");
std :: ofstream fout("lgput.out");

const int MOD = 1999999973;
unsigned long long ridicare_la_putere(unsigned long long x, unsigned long long n)
{
    unsigned long long result = 1;
    while (n > 0)
    {
        if (n & 1)
            result = (x * result) % MOD;

        x = (x * x) % MOD;
        n >>= 1;
    }

    return result;
}

int main() {
    unsigned long long x, n;
    fin >> x >> n;
    fout << ridicare_la_putere(x, n);
    return 0;
}