Cod sursa(job #304388)
Utilizator | Data | 12 aprilie 2009 14:58:41 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include<stdio.h>
#define c 1999999973
long long a,b,rez=1;
int main()
{
freopen("lgput.in","r",stdin);freopen("lgput.out","w",stdout);
scanf("%lld %lld",&a,&b);
while(b)
{
if(b%2==1)
rez=rez*a%c;
a=a*a%c;
b/=2;
}
printf("%lld",rez);
return 0;
}