Cut the sticks, cutthesticks

Source: Internet
Author: User

Cut the sticks, cutthesticks

1 def main (): 2 n = int (raw_input () 3 arr = map (int, raw_input (). strip (). split () 4 5 for I in range (n): 6 cutNum = 0 7 minValue = min (arr) 8 for _ in range (n ): 9 if 0 <arr [_] <100:10 arr [_]-= minValue11 cutNum + = 112 if arr [_] <= 0: # Make an inappropriate value, undun loop 13 arr [_] = 100114 if cutNum! = 0: # Two-layer loops are rich, so only the output is not 0. A dynamic adjustment of the encoding is 15 print cutNum16 17 main ()

Learning

Try

Pop and other operations

 

// New ideas

 1 n = int(raw_input().strip()) 2 sticks = [int(i) for i in raw_input().strip().split()] 3 sticks.sort() 4 newItem = sticks[0] 5 count = len(sticks) 6 print count 7 count -= 1 8 for i in range(1, len(sticks)): 9     if sticks[i] != newItem:10         newItem = sticks[i]11         print count12     count -= 1

Learning

The sequence is not important. It can be sorted first.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.