Cod sursa(job #2057723)
Utilizator | Data | 4 noiembrie 2017 17:53:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <stdio.h>
#define MOD 1999999973
int putere( int a, int b)
{
int sol = 1 ;
while(b)
{
if(b & 1) sol=(1LL*sol*a)%MOD;
a=(1LL*a*a)%MOD;
b >>= 1;
}
return sol;
}
int main()
{
int a , b ;
//lgput
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d%d", &a, &b);
printf("%d",putere(a,b));
return 0;
}