Finish Poj 2996

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