Cod sursa(job #2763375)

Utilizator Snake2003lalallalal Snake2003 Data 13 iulie 2021 14:27:05
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.53 kb
#include <iostream>
#include <fstream>

#define Mod 1999999973

using namespace std;

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

void LOG(int a, int b)
{
    long long res = 1;

    if(b == 0)
        fout << 1;
    if(b == 1)
        fout <<  a;

    while(b > 1)
    {
        if(b % 2 == 1)
            res = (res * a) % Mod;

        b /= 2;
        a = a * a;
    }
    fout << (res * a) % Mod;
}

int main()
{
    int baza, exp;

    fin >> baza >> exp;
    LOG(baza, exp);
    return 0;
}