Cod sursa(job #280896)
| Utilizator | Data | 13 martie 2009 17:21:56 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.41 kb |
#include <stdio.h>
long rez,n,p;
long putere(long x,long y)
{if(y==1)return x%1999999973;
if(y%2)return (putere(x,1)*putere(x,y/2)*putere(x,y/2))%1999999973;
else return (putere(x,y/2)*putere(x,y/2))%1999999973;
}
int main()
{freopen("lgput.in","r",stdin);freopen("lgput.out","w",stdout);
scanf("%ld%ld",&n,&p);
rez=putere(n,p);
printf("%ld",rez);
fclose(stdin);fclose(stdout);
return 0;
}