Cod sursa(job #670711)
Utilizator | Data | 29 ianuarie 2012 20:52:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include<cstdio>
#define c 1999999973;
int main()
{
long long a,b,p=1;
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld %lld",&a,&b);
a=a%c;
while (b)
{
if (b%2==1) p=(p*a)%c;
a=(a*a)%c;
b/=2;
}
printf("%lld\n",p);
return 0;
}