Cod sursa(job #2415821)

Utilizator andreisontea01Andrei Sontea andreisontea01 Data 26 aprilie 2019 15:33:29
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <bits/stdc++.h>

using namespace std;

const int mod = 1999999973;

long long pow(long long baza, long long exp){
    long long ans = 1;
    while(exp){
        if(exp % 2 == 1){
            ans *= baza;
            ans %= mod;
        }
        baza *= baza;
        baza %= mod;
        exp /= 2;
    }
    return ans;
}

int main()
{
    ifstream fin("lgput.in");
    ofstream fout("lgput.out");
    long long b, e;
    fin >> b >> e;
    fout << pow(b, e);
    return 0;
}