Pagini recente » Cod sursa (job #2502861) | Borderou de evaluare (job #1609980) | Cod sursa (job #2818173) | Cod sursa (job #648275) | Cod sursa (job #1803510)
#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;
}
if(x == zero(r + 1))
return r + 1;
return -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;
}