Cod sursa(job #264081)
Utilizator | Data | 21 februarie 2009 12:39:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include<stdio.h>
long long n,p,m,b,r;
void readd(),solve();
int main()
{
readd() ;
solve() ;
return 0 ;
}
void readd()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
m=1999999973;
}
void solve()
{
b=n;
r=1;
while(p)
{
if(p%2)r=(r*b)%m;
b=(b*b)%m;
p=p/2;
}
printf("%lld",r);
}