Cod sursa(job #911315)

Utilizator MIonutMistreanu Ionut MIonut Data 11 martie 2013 15:25:14
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include<fstream>
#define ull long long
using namespace std;
ull  a, b, c=1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
ull putere(ull x, ull n)
{
    if(n==0) return 1;
    else
    {
        ull aux=putere(x, n/2);
        if(n%2) return ((aux*aux)%c*x)%c;
        else return (aux*aux)%c;
    }
}
int main()
{
    f>>a>>b;
    g<<putere(a,b);
    return 0;
}