Cod sursa(job #3184489)

Utilizator darian4444Verniceanu Darian darian4444 Data 16 decembrie 2023 09:38:01
Problema Ridicare la putere in timp logaritmic Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

ll a,b,i,j,sol,mod=1999999973,x;

ll LogPower(ll b,ll p){
    if (p == 0)
        return 1;
    x = LogPower(b,p/2)%mod;
    if (p % 2 == 0)
        return (x*x)%mod;
    else
        return (b*(x*x)%mod)%mod;
}

int main()
{
    fin >> a >> b;
    fout << LogPower(a,b);
    return 0;
}