Cod sursa(job #3001979)

Utilizator tomaionutIDorando tomaionut Data 14 martie 2023 09:58:32
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.36 kb
#include <bits/stdc++.h>
#define MOD (int)1999999973
using namespace std;

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

int main()
{
    int b, e, p = 1;
    fin >> b >> e;
    while (e)
    {
        if (e % 2 == 1)
            p = (p * b) % MOD;
        b = (b * b) % MOD;
        e /= 2;
    }
    fout << p << "\n";


    return 0;
}