Blue Bridge Cup python group - card (card master..)

Blue Bridge Cup Python Group - Cards

Topic description

This question is a fill-in-the-blank question. After calculating the result, use the output statement in the code to output the filled result.

Little Blue has many number cards, and each card has numbers 0 to 9. Xiaolan is going to use these cards to spell some numbers. He wants to spell positive integers from 1. After each spelling, he saves them, and the cards cannot be used to spell other numbers. Xiaolan wants to know how much he can fight from 1. For example, when Xiaolan has 30 cards, including 3 cards from 0 to 9, Xiaolan can spell 1 to 10, but when he spells 11, there is only one card 1, which is not enough to spell 11. Now Xiaolan has 2021 cards from 0 to 9 in his hand, a total of 20210 cards. How many cards can Xiaolan get from 1? Tip: Computer programming is recommended for problem solving

Running limit
Maximum running time: 1s
Maximum running memory: 128M

import os
import sys
count=0
i=1
while True:
    count=str(i).count("1")+count
    #通过统计1的个数是不是达到了2021个就行,因为1肯定是消耗的最快的数字
    # print(count)
    if count==2021 :
        print(i)
        break
    elif count>2021:#有可能最后存在一个数只够拼一半的。。。为确保万无一失,再来一次判定
        print(i-1)
        break
    i=i+1

The answer is 3181
Thank you for your support. Your one-click three-connection is the biggest driving force for Ganggang students!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324322260&siteId=291194637