Cod sursa(job #1815500)

Utilizator triscacezarTrisca Vicol Cezar triscacezar Data 25 noiembrie 2016 12:27:41
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
#include <fstream>
#define MOD 1999999973
#define tip long long

using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
tip P(tip b,tip e)
{
    tip P=1;
    for(;e;e>>=1)
    {
        if(e&1)P=P*b%MOD;
        b=b*b%MOD;
    }
    return P;
}
tip b,e;
int main()
{
    f>>b>>e;
    g<<P(b,e);
    return 0;
}