Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize pressure-bearing calculation by Python

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to achieve pressure calculation in Python". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to achieve pressure calculation in Python" can help you solve the problem.

Description of the topic

This title is to fill in the blanks, you only need to calculate the results, and then use the output statement in the code to output the results.

Some precious metal materials are neatly stacked in Planet X's high-tech laboratory.

The shape and size of each metal raw material are exactly the same, but the weight is different. Metal materials are strictly stacked into pyramids.

7 5 8 7 8 8 9 2 7 2 8 1 4 9 1 8 1 8 8 4 1 7 9 6 1 4 5 4 5 6 5 5 6 9 5 6 5 5 4 7 9 3 5 5 1 7 5 7 9 7 4 7 3 3 1 4 6 4 5 5 8 8 3 2 4 3 1 1 3 3 1 6 6 5 5 4 4 2 9 9 9 2 1 9 1 9 2 9 5 7 9 4 3 3 7 7 9 3 6 1 3 8 8 3 7 3 6 8 1 5 3 9 5 8 3 8 1 8 3 3 8 3 2 3 3 5 5 8 5 4 2 8 6 7 6 9 8 1 8 1 8 4 6 2 2 1 7 9 4 2 3 3 4 2 8 4 2 2 9 9 2 8 3 4 9 6 3 9 4 6 9 7 9 7 4 9 7 6 6 2 8 9 4 1 8 1 7 2 1 6 9 2 8 6 4 2 7 9 5 4 1 2 5 1 7 3 9 8 3 3 5 2 1 6 7 9 3 2 8 9 5 5 6 6 6 2 1 8 7 9 9 6 7 1 8 8 7 5 3 6 5 4 7 3 4 6 7 8 1 3 2 7 4 2 2 6 3 5 3 4 9 2 4 5 7 6 6 3 2 7 2 4 8 5 5 4 7 4 4 5 8 3 3 8 1 8 6 3 2 1 6 2 6 4 6 3 8 2 9 6 1 2 4 1 3 3 5 3 4 9 6 3 8 6 5 9 1 5 3 2 6 8 8 5 3 2 2 7 9 3 3 2 8 6 9 8 4 4 9 5 8 2 6 3 4 8 4 9 3 8 8 7 7 7 9 7 5 2 7 9 2 5 1 9 2 6 5 3 9 3 5 7 3 5 4 2 8 9 7 7 6 6 8 7 5 5 8 2 4 7 7 4 7 2 6 9 2 1 8 2 9 8 5 7 3 6 5 9 4 5 5 7 5 5 6 3 5 3 9 5 8 9 5 4 1 2 6 1 4 3 5 3 2 4 1 X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X

The number represents the weight of the metal block (larger unit of measurement). The XX at the bottom represents 3030 extremely high-precision electronic scales.

Suppose that the weight of each raw material falls very accurately and evenly on the two metal blocks below, and finally, the weight of all the metal blocks is exactly evenly distributed on the lowest electronic scale.

The unit of measurement of the electronic scale is very small, so the number displayed is very large.

The staff found that the electronic scale with the lowest reading read as follows: 20864582312086458231

Please calculate: what is the number of the electronic scale with the highest reading?

Operating restrictions:

Maximum running time: 1s

Maximum running memory: 128m

Second, the way to solve the problem

Put the pyramid in the source code as a string

Create a double list, store all the elements in different lists in columns, and then store all the lists as one element in a large list. List = [[int (I) for i in j.split ()] for j in a.split ('\ n')]

Iterate through each element in each small list and calculate the total weight of the elements in the next column in turn:

List [I] [j] + = list [I] [j] / 2list [I] [j] + = list [I] [j] / 2

At the end of the traversal, the element of the last line is the total weight of each, which is calculated with the min () and max () functions.

Num1 = min (list [- 1]) num2 = max (list [- 1])

Finally, the output is converted to the result (2086458231/num1) * num2, but the result with division must contain decimals. At this time, you can force it to be an integer through int, which is relatively simple. You can also output as a format string, but only if you change the result to a float floating-point type

3. Source code sharing # @ File: pressure calculation. Pya ='7 5 8 7 8 8 9 2 7 2 8 1 4 9 1 8 8 4 1 7 9 6 1 4 5 4 5 6 5 5 6 9 5 6 5 5 4 7 9 3 5 5 1 7 5 7 9 7 4 7 3 3 1 4 6 4 5 5 8 8 3 2 4 3 1 1 3 3 1 6 6 5 5 4 4 2 9 9 9 2 1 9 1 9 2 9 5 7 9 4 3 3 7 7 9 3 6 1 3 8 8 3 7 3 6 8 1 5 3 9 5 8 3 8 1 8 3 3 8 3 2 3 3 5 5 8 5 4 2 8 6 7 6 9 8 1 8 1 8 4 6 2 2 1 7 9 4 2 3 3 4 2 8 4 2 2 9 9 2 8 3 4 9 6 3 9 4 6 9 7 9 7 4 9 7 6 6 2 8 9 4 1 8 1 7 2 1 6 9 2 8 6 4 2 7 9 5 4 1 2 5 1 7 3 9 8 3 3 5 2 1 6 7 9 3 2 8 9 5 5 6 6 6 2 1 8 7 9 9 6 7 1 8 8 7 5 3 6 5 4 7 3 4 6 7 8 1 3 2 7 4 2 2 6 3 5 3 4 9 2 4 5 7 6 6 3 2 7 2 4 8 5 5 4 7 4 4 5 8 3 3 8 1 8 6 3 2 1 6 2 6 4 6 3 8 2 9 6 1 2 4 1 3 3 5 3 4 9 6 3 8 6 5 9 1 5 3 2 6 8 8 5 3 2 2 7 9 3 3 2 8 6 9 8 4 4 9 5 8 2 6 3 4 8 4 9 3 8 8 7 7 7 9 7 5 2 7 9 2 5 1 9 2 6 5 3 9 3 5 7 3 5 4 2 8 9 7 7 6 8 7 5 5 8 2 4 4 7 7 7 2 6 9 2 1 8 2 9 2 7 7 7 2 6 9 2 1 8 2 9 8 5 7 3 5 9 4 5 7 5 6 3 5 3 9 5 8 9 5 4 1 6 1 3 5 3 2 4 1 0 0 0''list = [[int (I) for i in j.split ()] for j in a.split ('n')] for i in range (len (list [- 1])-1): for j in range (len (list [I]): list [iTun1] [j] + = list [I] [j] / 2 list [iTun1] [juni1] + = list [I] [j] / 2num1 = min (list [- 1]) num2 = max (list [- 1]) # print ('% .0f'% float ((2086458231/num1) * num2) This is the end of the introduction of print (int ((2086458231/num1) * num2)) on "how to realize pressure calculation by Python". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report