Cod sursa(job #723062)
| Utilizator | Data | 24 martie 2012 21:11:40 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include<stdio.h>
#define MOD 1999999973
using namespace std;
int n,p;
int main()
{
int i;
unsigned long long s,x;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d %d",&n,&p);
x=n;
s=1;
for(i=0;(1<<i) <= p;++i)
{
if( ((1<<i) & p) >0 )
s=(s*x)%MOD;
x=(x*x)%MOD;
}
printf("%lld",s);
fclose(stdin);
fclose(stdout);
return 0;
}
