当前位置:网站首页>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 那么直接跳过
边栏推荐
- Linux: Remember to install MySQL8 on CentOS7 (blog collection)
- How about Ping An Mengwa Card Insurance?Let parents read a few ways to identify products
- Nature:猪死亡1小时后,器官再次运转
- Support Vector Machine SVM
- 拓朴排序例题
- hdu4545 魔法串
- Google启动通用图像嵌入挑战赛
- 机器学习——逻辑回归
- nyoj1185最大最小值(线段树)
- How to write a blog with Golang - Milu.blog development summary
猜你喜欢
随机推荐
提取人脸特征的三种方法
Three methods for extracting facial features
hdu4545 Magic String
OpenHarmony如何查询设备类型
5G NR 系统消息
Android development with Kotlin programming language - basic data types
Linux: Remember to install MySQL8 on CentOS7 (blog collection)
Android development with Kotlin programming language three loop control
2022 CCF国际AIOps挑战赛决赛暨AIOps研讨会报名已开启
Hands-on Deep Learning_GoogLeNet / Inceptionv1v2v3v4
MMDetection实战:MMDetection训练与测试
2022技能大赛训练题:交换机snmp配置
Flink Yarn Per Job - JobManger 申请 Slot
停电。。。烦烦烦!!!
Image segmentation model - a combination of segmentation_models_pytorch and albumations to achieve multi-category segmentation
PostgreSQL 2022 Report: Rising popularity, open source, reliability and scaling key
可视化开发必看:智慧城市四大核心技术
Detailed explanation of PPOCR detector configuration file parameters
工程设备在线监测管理系统自动预警功能
Integration testing of software testing