当前位置:网站首页>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 那么直接跳过
边栏推荐
猜你喜欢
随机推荐
巴比特 | 元宇宙每日必读:中国1775万件数字藏品分析报告显示,85%的已发行数藏开通了转赠功能...
Mathcad 15.0软件安装包下载及安装教程
Machine Learning - Logistic Regression
华为分析&联运活动,助您提升游戏总体付费
Detailed explanation of PPOCR detector configuration file parameters
Student Information Management System (first time...)
问题征集丨ECCV 2022中国预讲会 · Panel专题研讨会
导火索:OAuth 2.0四种授权登录方式必读
安全软件Avast与赛门铁克诺顿NortonLifeLock合并获英国批准
负载均衡应用场景
2022 极术通讯-基于安谋科技 “星辰” STAR-MC1的灵动MM32F2570开发板深度评测
并非富人专属,一文让你对NFT改观
knife4j
lvgl 实现状态提示图标自动对齐补位显示
【名词】什么是PV和UV?
trie树模板
苹果Meta都在冲的Pancake技术,中国VR团队YVR竟抢先交出产品答卷
Google启动通用图像嵌入挑战赛
hdu4545 魔法串
【7.29-8.5】写作社区精彩技术博文回顾