← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscan(reader, &n, &k)

	c2 := make([]int, n)
	c5 := make([]int, n)

	for i := 0; i < n; i++ {
		var val int64
		fmt.Fscan(reader, &val)
		for val > 0 && val%2 == 0 {
			c2[i]++
			val /= 2
		}
		for val > 0 && val%5 == 0 {
			c5[i]++
			val /= 5
		}
	}

	// Maximum possible sum of factors of 5 is roughly n * 26.
	// For n=200, this is ~5200. We use 6000 as a safe upper bound.
	const max5 = 6000
	
	// dp[i][j] stores the max sum of factors of 2 using exactly i numbers with total factors of 5 equal to j.
	dp := make([][]int, k+1)
	for i := range dp {
		dp[i] = make([]int, max5)
		for j := range dp[i] {
			dp[i][j] = -1
		}
	}
	dp[0][0] = 0

	currMax := 0
	for i := 0; i < n; i++ {
		v2, v5 := c2[i], c5[i]
		// Iterate j from k down to 1 to behave like 0/1 knapsack (pick current item or not)
		for j := k; j >= 1; j-- {
			for p := currMax; p >= 0; p-- {
				if dp[j-1][p] != -1 {
					next5 := p + v5
					if next5 < max5 {
						next2 := dp[j-1][p] + v2
						if next2 > dp[j][next5] {
							dp[j][next5] = next2
						}
					}
				}
			}
		}
		currMax += v5
		if currMax >= max5 {
			currMax = max5 - 1
		}
	}

	ans := 0
	for j := 0; j < max5; j++ {
		if dp[k][j] != -1 {
			// Roundness is min(count of 2, count of 5)
			res := j
			if dp[k][j] < res {
				res = dp[k][j]
			}
			if res > ans {
				ans = res
			}
		}
	}
	fmt.Println(ans)
}
```