Cod sursa(job #1018336)
| Utilizator | Data | 29 octombrie 2013 13:24:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include<stdio.h>
using namespace std;
int n,p;
int putere(int x,int y)
{
int aux;
if(y==1)
return x;
aux=putere(x,y/2)%1999999973;
if(y%2==0)
return aux*aux%1999999973;
else
return aux*aux*x%1999999973;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d",&n,&p);
printf("%d",putere(n,p));
return 0;
}
