Cod sursa(job #795250)
| Utilizator | Data | 7 octombrie 2012 21:52:36 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.37 kb |
#include <stdio.h>
#define ll long long
#define MOD 1999999973
ll n,p;
ll lgput(ll n,ll p)
{
if (p==0)
return 1;
ll act=(lgput(n,p/2)*lgput(n,p/2))%MOD;
if (p & 1)
act=(act*n)%MOD;
return act;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&p);
n%=MOD;
printf("%lld\n",lgput(n,p));
return 0;
}
