Pagini recente » Cod sursa (job #125706) | Cod sursa (job #325275) | Cod sursa (job #2371997) | Cod sursa (job #2881028) | Cod sursa (job #3131842)
#include <stdio.h>
#include <math.h>
float exp_log_rec(float n, unsigned p){
if(p < 0) return exp_log_rec(1.0 / n, -p);
if(p == 0) return 1;
if(p % 2 == 0) return exp_log_rec(n*n, p/2);
if(p % 2 == 1) return n * exp_log_rec(n*n, p/2);
return 0;
}
int main(){
float n;
unsigned p;
freopen("lgput.in" , "r" , stdin);
freopen("lgput.out" , "w" , stdout);
if(scanf("%f %d" , &n , &p) == 2){
printf("%d" , (unsigned)exp_log_rec(n,p)%1999999973);
//printf("%lf" , pow(n,p)%1999999973);
}
return 0;
}