Cod sursa(job #314973)
| Utilizator | Data | 13 mai 2009 21:18:00 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.32 kb |
#include <stdio.h>
#define C 1999999973
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
long long a,b,p,sol=1;
scanf("%lld %lld",&a,&b);
p=a;
while(b)
{
if(b%2) sol=(sol*p)%C;
p=(p*p)%C;
b/=2;
}
printf("%lld\n",sol);
return 0;
}