Pagini recente » Cod sursa (job #511897) | Cod sursa (job #706786) | Cod sursa (job #1873928) | Cod sursa (job #1484373) | Cod sursa (job #1803504)
#include <stdio.h>
#define L 16
inline int zero(int n) {
int total = 0;
while(n) {
total += n / 5;
n /= 5;
}
return total;
}
int min;
inline int caut2(int x) {
int r = 0;
int pos = 1 << L;
while(pos) {
if(r + pos <= 1 << L && zero(r + pos) < x)
r += pos, min = r;
pos /= 2;
}
return r + 1;
}
FILE *fin, *fout;
int main() {
fin = fopen("fact.in", "r");
fout = fopen("fact.out", "w");
int p;
fscanf(fin, "%d", &p);
fprintf(fout, "%d", caut2(p));
fclose(fin);
fclose(fout);
return 0;
}