当前位置:网站首页>Cargo placement problem
Cargo placement problem
2022-07-07 13:57:00 【Beauty of algorithm and programming】
1. problem
Xiaolan has a huge warehouse , It can hold a lot of goods .
Now? , Xiao Lan has n Boxes of goods should be placed in the warehouse , Every box of goods is a cube of rules . Xiao Lan has set a long 、 wide 、 High three mutually perpendicular directions , The sides of each case must be strictly parallel to the length of the container 、 wide 、 high .
Xiao Lan hopes that all the goods will finally be placed into a big cube . That is in the long 、 wide 、 Stack separately in the high direction L、W、H Of goods , Satisfy n=L*W*H.
for example , When n=4 when , There are the following 6 Kind of plan :1*1*4、1*2*2、1*4*1、2*1*2、2*2*1、4*1*1.
Excuse me, , When n=2021041820210418 when , How many ways are there ?
2. Algorithm description
First write n Value , Then create a list ans, Variable i from 1 Traversing n The number after rounding off the square , If n Yes i The rest is 0, will i and n Yes i Rounding down of integer division is added to ans list , Then record each scheme that meets the conditions in the form of tuples , utilize set() Function de duplication , Use three cycles respectively in ans Take three numbers , If the three numbers are multiplied, they are equal to n, Add these three to set Element set , Finally, the length of the element set is the answer to the question .
3. Experimental results and discussion
Through the experiment 、 Practice has proved that the proposed method is effective , Is able to solve the problem raised at the beginning .
Code list 1
n = 2021041820210418 ans = [] for i in range(1,int(n**0.5)+1): if n % i == 0: ans.append(i) ans.append(n//i) case = set() for a in ans: for b in ans: for c in ans: if a * b * c == n: case.add((a,b,c)) print(len(case)) |
4 Conclusion
This article covers built-in set function 、for loop 、if Judgment of conditional statements and tuples , Article “**” It means power ,“//” Is an arithmetic operator , Represents integer division , You can return the integer part of the quotient ( Rounding down ), These knowledge points have been further consolidated , Through the experiment 、 Practice has proved that the proposed method is effective , It is able to solve the problems raised at the beginning .
边栏推荐
- 作战图鉴:12大场景详述容器安全建设要求
- 118. 杨辉三角
- [daily training] 648 Word replacement
- 云计算安全扩展要求关注的安全目标和实现方式区分原则有哪些?
- Laravel Form-builder使用
- 干货|总结那些漏洞工具的联动使用
- SSRF vulnerability file pseudo protocol [netding Cup 2018] fakebook1
- LIS longest ascending subsequence problem (dynamic programming, greed + dichotomy)
- 得物客服热线的演进之路
- How to check the ram and ROM usage of MCU through Keil
猜你喜欢
Show the mathematical formula in El table
C语言数组相关问题深度理解
SSRF vulnerability file pseudo protocol [netding Cup 2018] fakebook1
Use of polarscatter function in MATLAB
Flink | 多流转换
Cinnamon taskbar speed
Did login metamask
实现IP地址归属地显示功能、号码归属地查询
2022-7-6 Leetcode 977.有序数组的平方
The delivery efficiency is increased by 52 times, and the operation efficiency is increased by 10 times. See the compilation of practical cases of financial cloud native technology (with download)
随机推荐
Attribute keywords aliases, calculated, cardinality, ClientName
Es log error appreciation -limit of total fields
Vmware 与主机之间传输文件
move base参数解析及经验总结
Toraw and markraw
566. Reshaping the matrix
10 pictures open the door of CPU cache consistency
Move base parameter analysis and experience summary
PHP - laravel cache
How can the PC page call QQ for online chat?
Evolution of customer service hotline of dewu
Problems that cannot be accessed in MySQL LAN
.net core 关于redis的pipeline以及事务
Help tenants
Enregistrement de la navigation et de la mise en service du robot ROS intérieur (expérience de sélection du rayon de dilatation)
648. Word replacement: the classic application of dictionary tree
Fast development board pinctrl and GPIO subsystem experiment for itop-imx6ull - modify the device tree file
Getting started with cinnamon applet
PostgreSQL array type, each splice
Use day JS let time (displayed as minutes, hours, days, months, and so on)