当前位置:网站首页>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 那么直接跳过
边栏推荐
- Android 开发用 Kotlin 编程语言 二 条件控制
- Google启动通用图像嵌入挑战赛
- What do T and Z in the time format 2020-01-13T16:00:00.000Z represent and how to deal with them
- 今天告诉你界面控件DevExpress WinForms为何弃用经典视觉样式
- Machine Learning - Ensemble Learning
- Introduction to the Evolution of Data Governance System
- 【心里效应】98 个著名的心理效应
- Student Information Management System (first time...)
- 我要抓狂了。。又回到了几天不能A一道题的时候
- 一张图理解EOS是什么
猜你喜欢
随机推荐
金融业“限薪令”出台/ 软银出售过半阿里持仓/ DeepMind新实验室成立... 今日更多新鲜事在此...
五大理由告诉你为什么开发人员选择代码质量静态分析工具Klocwork来实现软件安全
工程设备在线监测管理系统自动预警功能
记2022年七夕感慨
DocuWare平台——文档管理的内容服务和工作流自动化的平台详细介绍(下)
【名词】什么是PV和UV?
PostgreSQL 2022 Report: Rising popularity, open source, reliability and scaling key
【心里效应】98 个著名的心理效应
API 网关简述
机器学习——逻辑回归
Machine Learning - Logistic Regression
Latex如何控制表格的宽度和高度
Go学习笔记(篇二)初识Go
时间格式2020-01-13T16:00:00.000Z中的T和Z分别表示什么,如何处理
微服务结合领域驱动设计落地
我要抓狂了。。又回到了几天不能A一道题的时候
Integration testing of software testing
结合“xPlus”探讨软件架构的创新与变革
Nature:猪死亡1小时后,器官再次运转
Discover the joy of C language







