🔌Longest piece that still makes K?
Cutting all cables into equal length L yields (length÷L) pieces per cable. Find the maximum L that can make at least 3 pieces.
Loading...
Cutting all cables into equal length L yields (length÷L) pieces per cable. Find the maximum L that can make at least 3 pieces.
An audio club is setting up a small concert stage. In the storage room there are a few audio cables of all different lengths. The members want to cut them all into 'equal-length' pieces to make at least K patch cables connecting mics and the mixer. From one cable you can get floor(length / L) pieces of a fixed length L, and the leftover is discarded. (A cable shorter than L yields no piece.) Shorter pieces let you make more, but if they are too short they won't reach across the stage. So the members want to meet the required count K while making each piece as long as possible. Find the maximum piece length L that still lets you make at least K pieces.
4 3 57 42 36 20
36
Cutting at L=36 gives 57//36 + 42//36 + 36//36 + 20//36 = 1+1+1+0 = 3 ≥ 3, which is enough. At L=37 it is 1+1+0+0 = 2 < 3, not enough. So the maximum L is 36.