Cod sursa(job #437086)
Utilizator | Data | 9 aprilie 2010 12:38:50 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<stdio.h>
#define MOD 1999999973
long long int b,e,T=1;
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&b,&e);
while(e)
{
if(e&1)
{
T*=b;
e--;
e/=2;
b*=b;
}
else
{
e/=2;
b*=b;
}
b%=MOD;
T%=MOD;
}
printf("%lld",T);
}