您的位置:首页 > 其它

HDOJ_ACM_Bone Collector

2012-11-20 16:09 375 查看
[align=left]Problem Description[/align]
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …
The bone collector had a big bag with a volume of V ,and along his trip of collecting there are a lot of bones , obviously , different bone has different value and different volume, now given the each bone’s value along his trip , can you calculate out the maximum of the total value the bone collector can get ?
View Code

[align=left]Key Points[/align]
[align=left]Firstly, you must realize it's a knapsack question. [/align]
For those question, you should know the function f(n, v) = max(f(n - 1, v), f(n - 1, v - vol
) + value
).
[align=left]f(n, v) means the greatest value of putting n things into knapsack whose volume is v.[/align]
vol
means the volume array.
value
means the value array.
If you don't choose the nth thing, it's f(n - 1, v), if you chooose the nth thing, it's f(n - 1, v - vol
) plus the nth thing's value.
[align=left]then the bigger answer is the f(n, v).[/align]
[align=left]Of course, you can using form to deepen understanding.[/align]
[align=left]For example, if you input those number as follows.[/align]
[align=left]1[/align]
[align=left]2 5[/align]
[align=left]3 4[/align]
[align=left]2 3[/align]

012345
0000000
1003333
2003447
[align=left] [/align]
[align=left]Secondly, I provide simpler program.[/align]
[align=left]If you understand the first kind, I think it's easy for you. [/align]
[align=left]What I want to express is that the second circulation should begin with max, or you will be wrong. Because you put the same thing again.[/align]

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: