Cod sursa(job #2014199)

Utilizator NashikAndrei Feodorov Nashik Data 23 august 2017 09:40:38
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
//#include <iostream>
#include <fstream>
using namespace std;
const long long mod=1999999973;

long long putere(long long n,long long e)
{
    long long prod;
    if(e%2==1)
        prod=n;
    else
        prod=1;
    if(e>1)
    {
        e/=2;
        n*=n;
        n%=mod;
        prod*=putere(n,e);
    }
    return prod;
}
ifstream cin("lgput.in");
ofstream cout("lgput.out");
int main()
{
    long long n,e;
    cin>>n>>e;
    cout<<putere(n,e);
    return 0;
}