Cod sursa(job #2868928)

Utilizator meinkampfEmanuel Pinzariu meinkampf Data 11 martie 2022 11:43:25
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>
using namespace std;

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

const int MOD = 1999999973;

int LogP(int a, int e)
{
    int p = 1;
    while (e > 0)
    {
        if (e & 1)
            p = 1LL * p * a % MOD;
        a = 1LL * a * a % MOD;
        e /= 2;
    }
    return p;
}

int main()
{
    int x, y;
    fin >> x >> y;
    fout << LogP(x, y) << '\n';
    return 0;
}