Cod sursa(job #3296480)
| Utilizator | Data | 13 mai 2025 03:01:52 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *f, *out;
if((f = fopen("lgput.in","r")) == NULL)
{
perror(NULL);
exit(-1);
}
if((out = fopen("lgput.out","w")) == NULL)
{
perror(NULL);
exit(-1);
}
int n, p;
fscanf(f,"%d %d",&n, &p);
long long prod = 1;
while(p)
{
prod = prod * n;
p--;
}
fprintf(out, "%lld", prod);
if(fclose(f) != 0)
{
perror(NULL);
exit(-1);
}
if(fclose(out) != 0)
{
perror(NULL);
exit(-1);
}
return 0;
}