Cod sursa(job #3265029)

Utilizator Alexbora13Bora Ioan Alexandru Alexbora13 Data 26 decembrie 2024 16:28:02
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.35 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=ans*b%m;
        b = b*b%m;
        e/=2;
    }
    fout << ans%m;
    return 0;
}