


全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第一题:用分支限界法解决最优装载问题(主要学习思想)二、问题描述给定 2n 个方格组成的一行方格。除了两个相邻的空方格外,其余每个方格中都放入了一枚金币或一枚银币。共有 n-1 枚金币和 n-1 枚银币。任何两个非空方格中的钱币可以移动到两个相邻的空格中,但不能改变线币的排列顺序。金币变换问题要求用最少移动次数将所有金币移到所有银币的左边。编程任务对于给定的 n-1 枚金币和 n-1 枚银币的初始排列,设计一个分支限界法,计算满足要求的最少移动次数。数据输入第一行有一个正整数 T ,表示有 T 组测试数据。每组测试数据包括两行,第一行是一个整数 n ,第二行是 n-1 枚金币,n-1 枚银币和两个空方格的初始排列,字母 a 表示金币,字母 b 表示银币,字符.表示空方格。0 T 1002 n 10数据输出对于每组测试数据,输出一行一个整数,表示最少需要移动的次数;如果无解,请输出一行“No Solution”。输入文件示例 输出文件示例输入33abab.5abba.abab6a.babbababa输出No Solution34 三、Description (此题比较难,符合竞赛题目的难度)N gangsters are going to a restaurant. The i-th gangster comes at the time Ti and has the prosperity Pi. The door of the restaurant has K+1 states of openness expressed by the integers in the range 0, K. The state of openness can change by one in one unit of time; i.e. it either opens by one, closes by one or remains the same. At the initial moment of time the door is closed (state 0). The i-th gangster enters the restaurant only if the door is opened specially for him, i.e. when the state of openness coincides with his stoutness Si. If at the moment of time when the gangster comes to the restaurant the state of openness is not equal to his stoutness, then the gangster goes away and never returns. The restaurant works in the interval of time 0, T. The goal is to gather the gangsters with the maximal total prosperity in the restaurant by opening and closing the door appropriately. Input The first line of the input file contains the values N, K, and T, separated by spaces. (1 = N = 100 ,1 = K = 100 ,0 = T = 30000 ) The second line of the input file contains the moments of time when gangsters come to the restaurant T1, T2, ., TN, separated by spaces. ( 0 = Ti = T for i = 1, 2, ., N) The third line of the input file contains the values of the prosperity of gangsters P1, P2, ., PN, separated by spaces. ( 0 = Pi = 300 for i = 1, 2, ., N) The forth line of the input file contains the values of the stoutness of gangsters S1, S2, ., SN, separated by spaces. ( 1 = Si = K for i = 1, 2, ., N) All values in the input file are integers. Output Print to the output file the single integer ?the maximal sum of prosperity of gangsters in the restaurant. In case when no gangster can enter the
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 备份文件备份周期统计表
- 食品加工工艺与安全规范考试卷
- 进销存软件开发服务合作协议
- 2025年信息安全与风险管理考试试题及答案
- 小儿高热惊厥的急救
- 2025年社会变迁与家庭教育考试试题及答案
- 2025年母婴护理师考试试题及答案
- 2025年应用统计学基础能力考试试卷及答案
- 2025年公共卫生管理课程考试试卷及答案
- 2025年儿童发展与家庭教育考试试卷及答案
- 烟机设备修理工滤棒成型
- 外来医疗器械清洗消毒操作流程课件
- 软件工程-机票预订系统-详细设计-报告
- 网络安全服务实施方案
- 楼长-层长工作职责
- 物理化学实验:实验一 溶解热的测定
- 天然草皮铺设施工方案
- 丹尼森组织文化模型
- Unix内核源码剖析
- 漫画版《幼儿园入学准备教育指导要点》
- 2023-2024学年海南省海口市小学语文六年级期末模考试卷附参考答案和详细解析
评论
0/150
提交评论