Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:竟然让一个普通的多重背包用了18xx秒很顺利地过了In Reply To:竟然让一个普通的多重背包用了18xx秒很顺利地过了 Posted by:fanhqme at 2009-06-08 18:58:29 > 设dp[i][j]为用前i种钱币,最少使用多少个第i种钱币的情况下可以凑出j个单位的钱。 > > 加上一个滚动数组 > > if (dp[j]!=-1)dp[j]=0; > else if (j>=A[i] && dp[j-A[i]]!=-1 && dp[j-A[i]]<C[i])dp[j]=dp[j-A[i]]+1; > else dp[j]=-1; > 这种方法不过就没天理了,大多数人都是这种方法吧 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator