Cod sursa(job #3124036)

Utilizator dragoncrackCandidatu Mario Luca dragoncrack Data 26 aprilie 2023 18:21:01
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.49 kb
#include <fstream>

using namespace std;

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

long long a, b;

long long int ridicare(long long term, long long putere, int mod)
{
    long long sol = 1;
    term %= mod;
    while (putere != 0)
    {
        if (putere % 2 == 1)
            sol = term * sol % mod;
        term = term * term % mod;
        putere /= 2;
    }
    return sol;
}

int main()
{
    fin >> a >> b;
    fout << ridicare(a, b, 1999999973);
}