Pagini recente » Cod sursa (job #2570663) | Cod sursa (job #1576355) | Cod sursa (job #1746126) | Cod sursa (job #704004) | Cod sursa (job #2723050)
import java.io.FileReader;
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
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("foo.in"));
PrintStream out = new PrintStream("foo.out");
int p = in.nextInt();
out.print(solution(p));
in.close();
out.close();
}
}