Finish Poj 3087

http://www.cnblogs.com/mobileliker/p/4095297.html