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