Cod sursa(job #2497943)

Utilizator NeacsuMihaiNeacsu Mihai NeacsuMihai Data 23 noiembrie 2019 12:43:34
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb
#include <iostream>
#include <fstream>

using namespace std;

long long putere (int x, int e)
{
    x=x%1999999973;
    if(e==0) return 1;
    else
    {
        if(e%2==0) return putere( x*x, e/2);
        else return x * putere(x*x, e/2);
    }
}

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

    int n, p;
    fin>>n>>p;

    fout<<putere(n, p)% 1999999973;


}