Cod sursa(job #1479155)
| Utilizator | Data | 30 august 2015 17:24:21 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | c | Status | done |
| Runda | Arhiva educationala | Marime | 0.57 kb |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
unsigned long hatLog(unsigned long n,int hat)
{
if(hat!=1)
{
if(hat%2==0)
return hatLog(n*n,hat/2);
else
return hatLog(n*n,hat/2)*n;
}
else
return n;
}
int main()
{
FILE *readfile,*writefile;
readfile=fopen("lgput.in","r");
writefile=fopen("lgput.out","w");
unsigned long alap;
int hat;
fscanf(readfile,"%lu %d",&alap,&hat);
fprintf(writefile,"%lu",hatLog(alap,hat));
return 0;
}
