Material decomposition.

The solution to http://dsalgo.openjudge.cn/dsmoochw7/1/.