Cod sursa(job #211864)
| Utilizator | Data | 3 octombrie 2008 19:11:35 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include<iostream.h>
#include <stdio.h>
const int m = 1999999973;
int main()
{
unsigned int n, p;
long long a;
a=1;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%u%u", &n, &p);
n%=m;
while(p)
{
if(p%2)
a=a*n%m;
n=(unsigned int)((long long)n*(long long)n%(long long)m);
p=p/2;
}
printf("%lld\n",a);
return 0;
}
