You are given one litre each of 0.5 M HCl and 0.2 M. The ratio in which they should be mixed so as to give maximum volume of 0.4 M HCl should be

(1 * 0.5) + (x * 0.2) = (1 + x) * 0.4

solve for x