Finish Poj 2993

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