背包问题、LIS及LCS.doc

  1. 1、本文档共23页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
背包问题、LIS及LCS

poj 1837 Balance (01背包变形) 分类:?DP(动态规划)2014-05-20 15:56?134人阅读?评论(0)?收藏?编辑?删除 Balance Time Limit:?1000MS ? Memory Limit:?30000K Total Submissions:?10065 ? Accepted:?6231 Description Gigel has a strange balance and he wants to poise it. Actually, the device is different from any other ordinary balance.? It orders two arms of negligible weight and each arms length is 15. Some hooks are attached to these arms and Gigel wants to hang up some weights from his collection of G weights (1 = G = 20) knowing that these weights have distinct values in the range 1..25. Gigel may droop any weight of any hook but he is forced to use all the weights.? Finally, Gigel managed to balance the device using the experience he gained at the National Olympiad in Informatics. Now he would like to know in how many ways the device can be balanced.? Knowing the repartition of the hooks and the set of the weights write a program that calculates the number of possibilities to balance the device.? It is guaranteed that will exist at least one solution for each test case at the evaluation.? Input The input has the following structure:? ? the first line contains the number C (2 = C = 20) and the number G (2 = G = 20);? ? the next line contains C integer numbers (these numbers are also distinct and sorted in ascending order) in the range -15..15 representing the repartition of the hooks; each number represents the position relative to the center of the balance on the X axis (when no weights are attached the device is balanced and lined up to the X axis; the absolute value of the distances represents the distance between the hook and the balance center and the sign of the numbers determines the arm of the balance to which the hook is attached: - for the left arm and + for the right arm);? ? on the next line there are G natural, distinct and sorted in ascending order numbers in the range 1..25 representing the weights values.? Output The output contains the number M representing the number of possib

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档