蓝桥杯刷题--python-8(2023 填空题)

 0幸运数 - 蓝桥云课 (lanqiao.cn)

res=0
for i in range (1,100000000):
    l_n=[]
    for j in str(i):
        l_n.append(int(j))
    if len(l_n) % 2 ==0:
        cur =len(l_n)>>1
        if sum(l_n[:cur])==sum(l_n[cur:]):
            res+=1
print(res)

 0有奖问答 - 蓝桥云课 (lanqiao.cn)

dfs

def bfs(score, qus):
    global res
    if qus>=31 or score==100:
        return
    if score == 70:
        res+=1

    bfs(score + 10, qus + 1)
    bfs(0, qus + 1)

res=0
bfs(0, 0)
print(res)

 dp

 

dp=list([0]*10 for _ in range (31))

dp[0][0]=1
for i in ran

你可能感兴趣的:(l蓝桥杯刷题python,蓝桥杯,职场和发展)