Cod sursa(job #2254650)

Utilizator AlexAboAbogatoaie Alexandru AlexAbo Data 5 octombrie 2018 17:52:23
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <fstream>

using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
typedef long long Int;
const Int Mod = 1999999973LL;
Int putere(Int b,Int e)
{
    if(e==0)return 1LL;
    Int r=putere(b,e/2);
    r=r*r%Mod;
    if(e%2)r=r*b%Mod;
    return r;
}
Int n,p;
int main()
{
    f>>n>>p;
    g<<putere(n,p);
    return 0;
}