Here, I need some help with solving question number 2. The statement of the question is huge and so I refrained from typing it. This is last year's ZIO paper.
So, I thought that rather than vanishing bacterias and then again increasing it, we could keep $K$ bacterias as it is and decrease the number of instructions $A, B, C$ by 1 each. Then we can try to form the rest of the bacterias $i.e (N-K)$ using the 'modified' instructions.
I tried but cannot reach $N$ and I also need to develop a generalized algorithm so that all the test cases are solved easily. Thanks in advance.
This is not an ongoing test.
All right, for part a, you start with 23 amoebas and need to finish with 114 for an increase of 91. A increases the number of amoebas by 6, B by 11, and C by 15. So you have the equation $6a+11b+15c=91$. Considering this equation mod 3 yields $$2b\equiv1\pmod3,b\equiv2\pmod3$$. If $b=3k+2$, our equation becomes
$$6a+33k+22+15c=91$$ $$6a+33k+15c=69$$ $$2a+11k+5c=23$$
$k\ge2$ yields no solutions, giving 2 possibilities. $2a+5c=23$ gives a solution of $a=4,c=3$ for a total of 9 instructions. If $k=1$, we have $b=5$ and $2a+5c=12$, yielding $a=1,c=2$. This has $8$ instructions, the best we can do.
Part b might be easier. Our equation is $6a+14b+15c=67$. We quickly get $c\equiv1\pmod2$ and $b\equiv2\pmod3$. Substituting as before,
$$6a+42k_1+28+30k_2+15=67$$ $$6a+42k_1+30k_2=24$$
Our k's are obviously both $0$, yielding $a=4,b=2,c=1$ for a total of $7$ instructions.
This method does not work as well on part c as all 3 coefficients are coprime. Our equation is $8a+11b+25c=128$. The best option may be to check all values of $c$, then checking mod 8. If $c=0$, we have $b\equiv0\pmod8$. Letting $b$ be as high as possible, we get $b=8,a=5$ for 13 instructions. If $c=1,8a+11b=103,3b\equiv7\pmod8$. Multiplying by 3 gives $b\equiv 5\pmod8$. This gives $(a,b,c)=(6,5,1)$ for 12 instructions. If $c=2,8a+11b=78,3b\equiv6\pmod8,b\equiv2\pmod8$ for $(7,2,2)$:$11$ instructions. If $c=3,8a+11b=53,3b\equiv5\pmod8,b\equiv7\pmod8$: no solution. Finally, if $c=4,8a+11b=28$ which again has no solutions. The optimal solution is $a=7,b=c=2$.