Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:这样做为什么错了,不是背包吗,难道有特殊数据

Posted by zhzz at 2008-09-28 15:17:44 on Problem 1837
In Reply To:Re:这样做为什么错了,不是背包吗,难道有特殊数据 Posted by:Shrek at 2008-06-03 14:16:45
> for(j=0;j<=15000;j++){
> 			if(N[i-1][j]){
> 				for(k=0;k<n;k++)N[i][j+num*M[k]]++;
> 
> 你这样正向循环只能针对挂在天平左边的砝码更新状态...如果在右边的话,正向循环会造成“一个砝码多次被挂”右边应该for(int j=15000;j>=0;--j)。根据钩子的正负值分开循环


不错的题目,背包还可以这么变形!!
正向、反向 让我 wa了好几次,现在是明白了~~~强

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator