Hi,
Let's say we need x mg from 1st compound, and y mg from 2nd compound.
0.20 × x + 0.40 × y = 40mg
0.30 × x + 0.20 × y = 30mg
0.20(x + 2y) = 40. => x + 2y = 200 => 2y=200-x
0.10(3x +2y) = 30. => 3x + 2y = 300
3x + (200 - x) = 300
2x = 100
x =50mg
50 + 2y = 200
2y = 150
y =75mg