π About the author: Hello, I'm brother cheshen, cheshen at No. 18 Fuxue road π₯
β‘ About - > Che Shen: the fastest time from the bedroom to the laboratory is 3 minutes, and the slowest time is 3.5 minutes (that half minute is actually waiting for the traffic light)
π Personal homepage: Drivers only need cars and hands, and the pressure comes from the paper_ Cheshen, 18 Fuxue Road_ CSDN blog
π₯ Official certification: high-quality creators in the field of artificial intelligence
π give the thumbs-up β comment β Collection = = form a habit (one button three times) π
β‘ I hope you can give me more support π€~ Let's come on together π
-
special column
Today is the first question of the 2021 provincial competition. Come on~
Brush one question every day without saying much. Brush the questions for nearly two years first. From 2020, if you have one together, you can join us!!!
Let's brush the questions together and impact the national competition!!!
Scan code My home page Group QR code on the left of the page.
Joining method: you can add me on the wechat business card below, and then pull you into the group. (remember the note code: I want to win the National Award)
Overview of the 12th Blue Bridge Cup in 2021
These are the questions in 2020. There are two types: result filling and program design. We brush one question every day. There is no problem in saving the game!
Card (title)
(total score of this question: 5 points)
Official practice system: https://www.lanqiao.cn/problems/1443/learning/
- > [problem description]
Xiaolan has a lot of digital cards, and the numbers on each card are 00 to 99. Xiaolan is going to use these cards to spell some numbers. He wants to spell positive integers from 11. Each time he spell one, he will save it. The card can't be used to spell other numbers. Xiaolan wants to know how much she can spell from 11. For example, when Xiaolan has 3030 cards, including 33 cards from 00 to 99, Xiaolan can spell 11 to 1010, but there is only one card 11 when spelling 1111, which is not enough to spell 1111. Now Xiaolan has 20212021 cards from 00 to 99, a total of 2021020210. How much can Xiaolan spell from 11? Tip: it is recommended to use computer programming to solve the problem
- > [result description]
This question is a blank filling question. You only need to calculate the result and use the output statement in the code to output the filled result.
analysis
By reading the question stem, this question - the difficulty is simple: β
Type of investigation: violence, filling in the blank
Investigate knowledge points: dictionary and enumeration
analysis:
According to the question stem, it's very simple. If we say that we are directly violent, we will reduce one piece after using a number. In this way, we have been testing the cycle, which is simple and rough!
Open it directly below!!!
code
Python code implementation:
Method 1:
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/3/5 20:01 # @Author: cheshen, 18 Fuxue Road # @Email : yurz_control@163.com # @File : Day11.py # 2021 from 0 to 9, 20210 in total n = 2021 number = ['0','1','2','3','4','5','6','7','8','9'] # Ten numeric characters num = {} # Using dictionary for i in number: if i not in num: num[i] = n print(num) # {'0': 2021, '1': 2021, '2': 2021, '3': 2021, '4': 2021, '5': 2021, '6': 2021, '7': 2021, '8': 2021, '9': 2021} # Cyclic iteration res = 0 # Set counter stop = 0 # Set exit identifier while True: if stop == 1: break # Set exit # Combined number res += 1 # Start stacking res_str = [x for x in str(res)] # Convert numbers into characters, and then separate numbers from multiple characters print(res_str) # For example: ['1', '2'] # Find and delete numbers in the dictionary for y in res_str: if y in num: num[y] -= 1 # If it contains a number, delete one if 0 in num.values(): # If the value of a number in num is 0, that is, it is used up, then stop the calculation and set the stop condition stop = 1 print(res) # You can spell the number 3181
Example 1:
Method 2:
num=0 #num is used to accumulate the number of times of the used number "1" for i in range(1,10000): num+=str(i).count("1") #How many times does 1 add to num if num>2021: #When the number of num exceeds 2021, the number of cards is insufficient break print(i-1)
Very fast~
The final result is 3181
Today, the first question of 2021 provincial competition, come on!
Thus, we can quickly get the results, and the verification is completed!
Today is the 11th day of brush, the difficulty is general. Welcome to join us, become stronger together, self-discipline together, and go to the national competition together!!!
Today's topic is generally ha. If you have different solutions, you can leave a message below~
Previous question brushing route:
Question brushing route | Detail |
---|---|
2020 | |
Day-01 | Make doorplate |
Day-02 | Looking for 2020 |
Day-03 | Running exercise |
Day-04 | Serpentine filling number |
Day-05 | sort |
Day-06 | Decorative beads |
Day-07 | Achievement statistics |
Day-08 | Word analysis |
Day-09 | Digital triangle |
Day-10 | Plane segmentation |
β | β |
2021 | |
Official question brushing exercise system: http://lx.lanqiao.cn/
β€ Keep reading Paper, keep taking notes, keep learning, and keep brushing LeetCode β€!!!
Insist on writing questions!!! Impact national competition
β‘To Be No.1
β‘β‘ Ha ha ha ha
β‘ Creation is not easy β‘οΌ Crossing energy β€ Follow, collect and like β€ Three is the best
α¦( Β΄ο½₯α΄ο½₯` )
β€