hdu 4628(状态压缩)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4628

思路:首先把所有的回文找出来,如果当前状态为回文,则dp[state]=1,否则dp[state]=inf.然后就是枚举所有的状态:若当前状态为state,枚举子状态(substate=(substate-1)&state),则有dp[state]=min(dp[state],dp[substate^state]+dp[substate])(其中(substate^state)表示删除substate后的状态。最后就是要求dp[(1<<len)-1]了。

http://paste.ubuntu.com/5931156/

 

posted @ 2013-07-31 09:58  ihge2k  阅读(355)  评论(0编辑  收藏  举报