快捷搜索:

2022年第十三届蓝桥杯省赛B组python题目&部分解题

试题A:排列字母

解答:

msg = input()
print("".join(sorted(msg)))
# 答案:AAAEEEEEEHHHIIILLRRRSSTTWWWY

试题B:寻找整数

解答:

试题C:纸张尺寸

解答:

试题D:数位排列

解答:

试题E:蜂巢

没找到解答

试题F:消除游戏

解答:

s = list(input())
pre = s
f = False
for i in range(pow(2, 64)):
    flag = [False]*len(s)
    for j in range(1, len(s)-1):
        if s[j] == s[j-1] and s[j] != s[j+1]:
            flag[j] = True
            flag[j+1] = True
        if s[j] != s[j-1] and s[j] == s[j+1]:
            flag[j-1] = True
            flag[j] = True
    for j in range(len(flag)):
        if flag[j]:
            s[j] = 
    s = list(.join(s))
    if len(s) == 0:
        f = True
        break
    if pre == s:
        break
    pre = s


if f:
    print(EMPTY)
else:
    print(.join(s))

试题G:全排列的价值

试题H:技能升级

试题I:最长不下降子序列

试题J:最有清零方案

经验分享 程序员 微信小程序 职场和发展