Cod sursa(job #500047)
Utilizator | Data | 11 noiembrie 2010 11:51:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<cstdio>
void read(),solve();
long long n,p,r=1,f,m=1999999973;
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
f=n;
}
void solve()
{
for(;p;p/=2)
{
if(p%2)r=(r*f)%m;
f=(f*f)%m;
}
printf("%lld",r);
}