http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1006&cid=843