Cod sursa(job #811579)
| Utilizator | Data | 12 noiembrie 2012 18:00:35 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include<cstdio>
using namespace std;
#define m 1999999973
void read(),solve();
long long n,p,b,r,e;
int main()
{
read();
solve();
return 0;
}
void read()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
}
void solve()
{
for(b=n,r=1,e=p;e;e/=2)
{
if(e%2==1) r=(r*b)%m;
b=(b*b)%m;
}
printf("%lld\n",r);
}
