Cod sursa(job #1345941)

Utilizator AncaSScarlat Elena Anca AncaS Data 17 februarie 2015 22:23:53
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.5 kb
# include<cstdio>
using namespace std;
FILE *f=freopen("lgput.in","r",stdin);
FILE *g=freopen("lgput.out","w",stdout);

inline int putere(int x, int y)
{
    if( y == 0) return 1;
    if( y % 2 == 0) { int p = putere(x, y/2);
                       return p *p;}
    else{ int p = putere(x, y / 2);
          return p * p * x;
    }
}


int main()
{
    int x,y;
    unsigned long long z;
    scanf("%d%d",&x,&y);
    z=putere(x,y);
    printf("%lld",z % 1999999973);
    return 0;

}