solve p017 (the result can be better)