Blue Bridge Cup Question Record - Card

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 the numbers 00 to 99 on it.

Xiaolan is going to use these cards to spell some numbers. He wants to spell out positive integers starting from 11. Every time he spells one, he will save it. The cards cannot be used to spell other numbers.

Blue wants to know how much she can spell from 11.

For example, when Blue has 3030 cards, including 33 cards from 00 to 99, then Blue can spell 11 to 1010,

But when spelling 1111, there is only one card 11, which is not enough to spell 1111.

Now Xiaolan has 20212021 cards from 00 to 99 in his hand, a total of 2021020210 cards, how many cards can Xiaolan get from 11?

Tip: It is recommended to use computer programming to solve the problem.

import os
import sys

a=2021
b=2021
c=2021
d=2021
e=2021
f=2021
g=2021
h=2021
q=2021
k=2021
for j in range(0,10000):
    j=str(j)
    a=a-j.count('1')
    if a<0:
        break
    b=b-j.count('2')
    if b<0:
        break
    c=c-j.count('3')
    if c<0:
        break
    d=d-j.count('4')
    if d<0:
        break
    e=e-j.count('5')
    if e<0:
        break
    f=f-j.count('6')
    if f<0:
        break
    g=g-j.count('7')
    if g<0:
        break
    h=h-j.count('8')
    if h<0:
        break
    q=q-j.count('9')
    if q<0:
        break
    k=k-j.count('0')
    if k<0:
        break
j=int(j)
print(j-1)

 

Supongo que te gusta

Origin blog.csdn.net/qq_52045638/article/details/129784650
Recomendado
Clasificación