Minimum containers of given volumes for packing whole volume of a liquid

51 Views Asked by At

Suppose there are containers with volumes(integers) $V1, V2, \cdots, VN$ where $V1 =1$, and rest of the containers are distinct but not necessarily consecutive. Each container can be available/used more than once for filling liquids.

Is there a formula rather than use brute-force to calculate minimum number of containers(irrespective of capacity) required to pack exactly a liquid of volume(integer) "$V$"?

1

There are 1 best solutions below

0
On

Should be something along the lines of:

$f(v, n) = floor(v/n)$ if v % n = 0

$f(v, n) = 1 + floor(v/n)$ if v % n $\ne$ 0