当前位置:网站首页>hdu1455 Sticks (search+pruning+pruning+.....+pruning)
hdu1455 Sticks (search+pruning+pruning+.....+pruning)
2022-08-05 11:38:00 【51CTO】
Sticks
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 10325 Accepted Submission(s): 3091
Problem Description
George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the original state, but he forgot how many sticks he had originally and how long they were originally. Please help him and design a program which computes the smallest possible original length of those sticks. All lengths expressed in units are integers greater than zero.
Input
The input contains blocks of 2 lines. The first line contains the number of sticks parts after cutting, there are at most 64 sticks. The second line contains the lengths of those parts separated by the space. The last line of the file contains zero.
Output
The output file contains the smallest possible length of original sticks, one per line.
Sample Input
9 5 2 1 5 2 1 5 2 1 4 1 2 3 4 0
Sample Output
6 5
Source
Recommend
lcy | We have carefully selected several similar problems for you: 1258 1067 1045 2553 1426
Statistic |
Submit |
Discuss |
Note
I feel like I'm going to die 参考了别人的代码 understood overnight
自己敲了下.在hdu过了 可是在 nyoj293死活TLE..
Obviously the same code as others.last order 变量名 什么都改 还是不行..我选择死亡 nyojI don't brush it anymore
对于这道题而言 The importance of pruning in search is vividly reflected.
剪枝1:The length of the stick The longer the binding, the greater the force,less flexibility(The fewer lengths that can be combined),So first sort the length of the small sticks
剪枝2:The sum of the lengths of all the sticks must divide the length of the original stick
剪枝3:If we have used wooden sticks4 5 6Unable to complete stitching,下次再出现5 4 6肯定是不可能的 So avoid this when searching
剪枝4:If the result of the current search is correct,for each small stick 都要使用,如果发现没有使用 直接退出
剪枝5:If the length of the current stick is equal to the length needed to splice the stick ,And the stick was not used,那么直接退出.(Even find a few combinations smaller than him for this stick length 也是无用)
剪枝6:If the current length of the stick has already been present and has not been used 那么直接跳过
边栏推荐
- [7.29-8.5] Review of wonderful technical blog posts in the writing community
- 5G NR 系统消息
- .NET in-depth analysis of the LINQ framework (6: LINQ execution expressions)
- OpenHarmony如何查询设备类型
- 机器学习——集成学习
- CenOS MySQL入门及安装
- 智源社区AI周刊No.92:“计算复杂度”理论奠基人Juris Hartmanis逝世;美国AI学生九年涨2倍,大学教师短缺;2022智源大会观点报告发布[附下载]
- What do T and Z in the time format 2020-01-13T16:00:00.000Z represent and how to deal with them
- The fuse: OAuth 2.0 four authorized login methods must read
- STM32入门开发:编写XPT2046电阻触摸屏驱动(模拟SPI)
猜你喜欢
手把手教你定位线上MySQL慢查询问题,包教包会
CenOS MySQL入门及安装
互联网行业凛冬之至,BATM的程序员是如何应对中年危机的?
智源社区AI周刊No.92:“计算复杂度”理论奠基人Juris Hartmanis逝世;美国AI学生九年涨2倍,大学教师短缺;2022智源大会观点报告发布[附下载]
双因子与多因子身份验证有什么区别?
PG优化篇--执行计划相关项
TiDB 6.0 Placement Rules In SQL Usage Practice
机器学习——逻辑回归
《分布式云最佳实践》分论坛,8 月 11 日深圳见
DocuWare平台——文档管理的内容服务和工作流自动化的平台详细介绍(下)
随机推荐
hdu4545 Magic String
Apache APISIX Ingress v1.5-rc1 发布
【MySQL基础】-【数据处理之增删改】
Android 开发用 Kotlin 编程语言 二 条件控制
PostgreSQL 2022 Report: Rising popularity, open source, reliability and scaling key
Four, kubeadm single master
abc262-D(dp)
How to write a blog with Golang - Milu.blog development summary
停电。。。烦烦烦!!!
平安萌娃卡保险怎么样?让父母读懂几个识别产品的方法
How OpenHarmony Query Device Type
灰度值与热成像理解
结合“xPlus”探讨软件架构的创新与变革
Http-Sumggling Cache Vulnerability Analysis
Android development with Kotlin programming language three loop control
硅谷来信:快速行动,Facebook、Quora等成功的“神器”!
DocuWare平台——文档管理的内容服务和工作流自动化的平台详细介绍(下)
Web3 中的安全问题和防范
I'm going crazy.Again A few days can not be A problem
Nature:猪死亡1小时后,器官再次运转