Cod sursa(job #2915607)

Utilizator alexandru_ioan.06Alexandru Ioan alexandru_ioan.06 Data 23 iulie 2022 17:25:53
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#define LL unsigned long long int
#define MOD 1999999973
using namespace std;
LL a,b;
ifstream cin ("lgput.in");
ofstream cout ("lgput.out");
int power(LL base, LL exp)
{
    if(!exp) return 1;
    if(!(exp%2))
    {
        LL current=power(base,exp/2);
        return ((current%MOD)*(current%MOD))%MOD;
    }
    else return (base*(power(base,exp-1)%MOD)%MOD);
}
int main()
{
    cin>>a>>b;
    cout<<power(a,b);
}