Cod sursa(job #2583422)

Utilizator As932Stanciu Andreea As932 Data 18 martie 2020 11:41:54
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <iostream>
#include <fstream>
#define ll long long
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");

ll power(ll base,ll exp)
{
    if(exp==0)
        return 1;
    if(exp%2==0)
    {
        ll x=power(base,exp/2);
        return x*x;
    }
    return base*power(base,exp-1);
}

int main()
{
    long long n,p;
    fin>>n>>p;
    fout<<power(n,p)%mod;

    return 0;
}