problem 1007 of pku online judge