Cod sursa(job #3298155)
Utilizator | Data | 27 mai 2025 16:14:14 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | c-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <stdio.h>
unsigned test(unsigned N, unsigned P) {
if (P == 0)
return 1;
if (P % 2)
return N * test(N * N, (P - 1) / 2);
else
return test(N * N, P / 2);
}
int main() {
unsigned N, P;
scanf("%d %d", &N, &P);
printf("%d", test(N, P));
}