Cod sursa(job #3030003)

Utilizator NathanBBerintan Emanuel Natanael NathanB Data 17 martie 2023 13:05:08
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
typedef long long ll;
const ll mod = 1999999973;

ll logpow(ll x,ll y)
{
    ll rez=1;
    while(y>0)
    {if(y%2==1)
        rez = ((rez%mod)*(x%mod))%mod;
    x = ((x%mod)*(x%mod))%mod;
    y/=2;
    }
    return rez%mod;
}

int main()
{
    ll n,p;
    fin>>n>>p;
    fout<<logpow(n,p);
}