Cod sursa(job #3265030)

Utilizator Alexbora13Bora Ioan Alexandru Alexbora13 Data 26 decembrie 2024 16:28:37
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.36 kb
#include <bits/stdc++.h>
#define cnst const int
using namespace std;

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

int b, e;
cnst m = 1999999973;

int main()
{
    fin >> b >> e;
    long long ans = 1;
    while(e > 0)
    {
        if(e % 2 == 1)
            ans=1ll*ans*b%m;
        b = 1ll*b*b%m;
        e/=2;
    }
    fout << ans%m;
    return 0;
}