题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1082
题解:http://www.cnblogs.com/hadilo/p/5924546.html