Q : There's someone who He can form a nice toy using one of the following ways: • Two eyes and a body. • Two eyes, mouth and a body. • Eye, mouth and a body.
If he has n eyes, m mouths and k bodies, what is the largest number of toys that can be made by the king?
like : 1 2 3 => 1 14 21 23 => 14
but i want a formula to calculate it easily
Clearly you shouldn't make any toys that need two eyes, a mouth, and a body because that doesn't give you anything over the toy that needs two eyes and a body. If you make $a$ toys that need two eyes and a body and $b$ toys that need one of each you can write three constraint equations: $$2a+b \le n\\b \le m \\a+b \le k$$ You want to maximize $a+b$. There is a whole field of linear programming that is set up to answer questions like this. For this one it is easy to see you should just line up all the bodies, put a mouth with each until you run out of mouths or bodies, put an eye with each pair, then if you have eyes and bodies left over put two eyes with the bodies until you run out of one.
You have $\max (k,m)$ body/mouth pairs. If there are more eyes than this that is $b$, otherwise you run out of eyes and make $n$ toys. You have $max (k-m,0)$ bodies left over. If you haven't run out of eyes you have $n-b$ eyes left and make $\frac 12(n-b)=a$ more toys.