Cod sursa(job #211822)
Utilizator | Data | 3 octombrie 2008 18:21:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include<stdio.h>
int main()
{
int a,b,n,p;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d%d",&n,&p);
a=1;
while(p!=0)
{
if(p%2!=0)
{
a=a*n;
n=n*n;
p=p/2;
}
}
b=a%1999999973;
printf("%d",b);
return 0;
}