Cod sursa(job #988422)
| Utilizator | Data | 22 august 2013 19:58:39 | |
|---|---|---|---|
| Problema | Factorial | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<stdio.h>
int P, N, k;
int power(int x){
if(x >= N)
return 0;
else
return 1 + power(x * 5);
}
int main(){
FILE *pf, *pg;
pf = fopen("fact.in", "r");
pg = fopen("fact.out", "w");
fscanf(pf, "%d", &P);
N = P * 5;
if(P == 0)
N = 1;
else
if(N > 5){
k = power(5);
N = N - 5 * (k - 1) * k / 2;
}
fprintf(pg, "%d", N);
fclose(pf);
fclose(pg);
return 0;
}
