Let's assume that the two cans have the same capacity (for example, 5 litres).
The amount of red in C is 1/(1+4)=1/5. So if C is the quantity of paint, C/5 (litres) is the amount of red.
If D is the quantity of paint in can D, then there is 1/(1+9)=1/10 of D, that is, D/10 (litres) of red.
When we add the cans together we get C/5+D/10=(2C+D)/10 litres of red in C+D litres of pink mixture.
When the ratio of red:white in the mixture is 1:5, then (C+D)/6 is the quantity of red. Therefore:
(2C+D)/10=(C+D)/6; 12C+6D=10C+10D, 2C=4D, C=2D, that is, 2 cans of C and one of D.
Let's check this out. If the quantity of paint in each can is 5L, then there was 2L of red in 2 cans of C and ½L of red in one can of D.
Two cans of C (10L) contain 2L of red, so the total quantity of red is 2½L in 10L+5L=15L of pink mixture. The remaining 12½L is white. The ratio of red to white is 2½/12½=1/5 or 1:5.
So the method works! When the ratio is 1:6, we have (2C+D)/10=(C+D)/7, 14C+7D=10C+10D, 4C=3D. So C/D=3/4, or 3 cans of C and 4 of D.
Check this out using 5L cans: 15L of C contain 3L of red, and 20L of D contain 2L of red, making 5L of red in 35L of mixture. So there are 30L of white, and the ratio of red:white=5/30=1:6.
Now the ratio 1:7: (2C+D)/10=(C+D)/8; 16C+8D=10C+10D, 6C=2D, C/D=1/3. 1 can of C and 3 of D.
1:8: (2C+D)/10=(C+D)/9; 18C+9D=10C+10D, 8C=D, C/D=1/8. 1 can of C and 8 of D.