Cod sursa(job #2908849)

Utilizator ciobyCiobanu Vlasie cioby Data 6 iunie 2022 15:56:05
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
ifstream fin("date.in");
ofstream fout("date.out");


ull a,b;
const long modulo=1999999973;

ull putere(ull a,ull b){

    ull p=1;
    while(b){
        if (b%2==1){
            p=p*a;
            p=p%modulo;
        }
        a=a*a;
        b/=2;
    }
    return p;
}

void solve(){

    fin>>a>>b;
    ///a la putere b
    ull ans=putere(a,b);
    fout<<ans;
}

int main(){
    solve();
}