Choose exactly numbers to maximize the number of trailing zeros in their product.
You are given integers and an integer . Choose exactly of the integers so that the product of the chosen numbers has as many trailing zeros as possible.
A trailing zero is created by a factor of $10, and each factor of \10 comes from one factor of \2 and one factor of \5$.
Your task is to compute the maximum possible number of trailing zeros in the product of any selected numbers.
For each number, count how many times it is divisible by $2 and by \5k that maximizes the minimum of the total number of \2s and total number of \5$s in the chosen subset.
Print one integer — the maximum number of trailing zeros in the product of exactly chosen integers.
Note: The exact original contest constraints are not required for practice here.
Example 1
Input
5 3 10 20 25 4 5
Output
2
Explanation
Choose 10, 20, and 25. Their product is 5000, which has 3 trailing zeros? Let's verify factors: 10 contributes one 2 and one 5, 20 contributes two 2s and one 5, 25 contributes two 5s. Total is 3 twos and 4 fives, so the product has min(3,4)=3 trailing zeros. Therefore the maximum is 3.
Example 2
Input
4 2 2 5 8 25
Output
2
Explanation
Choosing 8 and 25 gives , which has 2 trailing zeros. No other pair does better.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.