Pagini recente » Cod sursa (job #3232791) | Cod sursa (job #1327296) | Cod sursa (job #685363) | Cod sursa (job #1152033) | Cod sursa (job #2722902)
import java.io.*;
import java.util.Scanner;
public class Main {
public static int countZeros(int n) {
int count = 0;
while (n > 0) {
count += n / 5;
n /= 5;
}
return count;
}
public static int solution(int p) {
int pos, step;
for (pos = -1, step = 1 << 30; step > 0; step >>= 1)
if (countZeros(pos + step) < p)
pos += step;
return pos < 0 ? 1 : pos + 1;
}
public static void main(String[] args) throws FileNotFoundException, IOException {
Scanner in = new Scanner(new FileReader("fact.in"));
PrintStream out = new PrintStream("fact.out");
int p = in.nextInt();
out.print(solution(p));
in.close();
out.close();
}
}