Cod sursa(job #3184488)

Utilizator darian4444Verniceanu Darian darian4444 Data 16 decembrie 2023 09:34:27
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.4 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;

ll LogPower(ll b,ll p){
    sol = 1;
    while (p){
        if (p % 2 == 1)sol = (sol*b)%mod;
        b = (b*b)%mod;
        p/=2;
    }
    return sol;
}

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