Cod sursa(job #3227527)
| Utilizator | Data | 1 mai 2024 18:49:17 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <stdio.h>
float exp_log_rec(float x, int n) {
if(n < 0) {
return exp_log_rec(1.0 / x, -n);
}
if(n == 0) {
return 1;
}
if(n % 2 == 0) {
return exp_log_rec(x*x, n/2);
}
if(n % 2 == 1) {
return x * exp_log_rec(x*x, n/2);
}
return 0;
}
int main() {
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
float nr = 0;
int exp = 0;
scanf("%f%d", &nr, &exp);
printf("%d", (int)exp_log_rec(nr, exp) % 1999999973);
return 0;
}
