Pagini recente » Cod sursa (job #1434797) | Cod sursa (job #1366431) | Cod sursa (job #158696) | Cod sursa (job #1650651) | Cod sursa (job #988588)
Cod sursa(job #988588)
#include<stdio.h>
int P, N, k, q = 1;
int power(int x){
if(x >= N)
return 0;
else{
q = q * 5;
return 1 + power(x * 5);
}
}
int count(int q){
if(q * 4 <= N)
return 4;
else
if(q * 3 <= N)
return 3;
else
if(q * 2 <= N)
return 2;
}
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) - 1;
printf("q = %d\n", q);
N = N - 20 * (k - 1) * k / 2 - (count(q)) * 5 * k;
}
fprintf(pg, "%d", N);
fclose(pf);
fclose(pg);
return 0;
}