How to solve equation with multiple variables with each of them having different "weight"? I need to solve equation where the goal is to buy specific number of snacks for the lowest price.
There are 7 types of snack packages, each of them contains different number of snacks and has different price, here is the list:

*

*A: 0.0051 $ / 4 snacks


*B: 0.0102 $ / 4 snacks


*C: 0.0204 $ / 8 snacks


*D: 0.0408 $ / 17 snacks


*E: 0.0816 $ / 35 snacks


*F: 0.1632 $ / 58 snacks


*G: 0.3264 $ / 58 snacks
Now I need to know, how to get the best "combo of packages" for lowest price when buying 10 snacks, 20 snacks..... up to 100 snacks. (When 10 is needed, buying some extra is not problem - such as buying 12 instead of 10.)
I tried bruteforcing (such as starting from maximum number of cheapest package and then combining with other packages), but I think there mast be some smarter way to solve this. :)

You want to minimize the total cost, i.e.,
$$0.0051A+0.0102B+0.0204C+0.0408D+0.0816E+0.01632F+0.3264G$$
under the condition that
$$ 4A+4B+8C+17D+25E+58F+58G\geq T,$$
where $T$ is your target number of snacks. Given prices and quantities of snaks per package, the solution will be such that $G=0$ (because $F$ includes the same number of snacks and it's half the price) and $C>0$ implies that the solution is not unique (as $B$ results in the same price per snack).
