# 第十三届蓝桥杯大赛 python B组题解交流

## 第一题

``````#coding=utf-8
msg = input()
print("".join(sorted(msg)))
``````

## 第二题：

``````#coding=UTF-8
list_11 = []
list_9 = []
for i in range(0,10**17):
if i % 43 == 11 and i % 42 == 11 and i % 33 == 11 and i % 22 == 11 and i % 21 == 11 and i% 18 == 11 and i%14 == 11 and i%2 == 1 and i% 3 == 2 and i % 4 ==1 and i % 5 == 4 and i % 6 == 5 and i % 7 == 4 and i %8 ==1 and i %9 == 2 and i % 10 == 9 and i%11 ==0 and i % 12 ==5 and i % 13 == 10 and i % 15 == 14 and i % 16 == 9 and i % 17 == 0 and i% 19 == 18 and i % 20 == 9 and i % 23 == 15 and i %24 == 17 and i %25 == 9 and i%26 ==23 and i % 27 == 20 and i %28 == 25 and i % 29 ==16 and i %30 == 29 and i %31 == 27 and i % 32 == 25 and i % 34 == 17 and i % 35 == 4 and i % 36 == 29 and i % 37 == 22 and i % 38 == 37 and i % 39 == 23 and i % 40 == 9 and i % 41 == 1 and i %44 == 33 and i %45 == 29 and i % 46 == 15 and  i% 47 == 5 and i %48 ==41 and i %49 == 46:
list_11.append(i)
print(i)
``````

## 第三题

``````#coding=utf-8
size_x = 1189
size_y = 841

def duce(n,size_x,size_y,target):
if n != target:
if size_x > size_y:
duce(n+1,int(size_x/2),int(size_y),target)
else:
duce(n+1,int(size_x),int(size_y/2),target)
else:
if size_x > size_y:
print(size_x)
print(size_y)
else:
print(size_y)
print(size_x)

msg = input("")[-1]
duce(0,size_x,size_y,int(msg))
``````

## 第四题

``````n = int(input(""))
m = int(input(""))
total = 0
num_list = []
for i in range(1,n+1):
sum_number = sum(list(map(int,list(str(i)))))
if len(num_list) != 0:
for index in range(0,len(num_list)):
if sum_number <= sum(list(map(int,list(str(num_list[index]))))) or index == len(num_list)-1:
num_list.insert(index+1,i)
break
else:
num_list.append(i)
print(num_list[m-1])
``````

## 第六题

``````msg = list(input(""))
flag = True

while flag == True:
point_list = []
flag = False
for index in range(1,len(msg)-1):
try:
if (msg[index] == msg[index-1] and msg[index] != msg[index+1]):
point_list.append(index+1)
point_list.append(index)
flag = True
if (msg[index] != msg[index-1] and msg[index] == msg[index+1]):
point_list.append(index)
point_list.append(index-1)
flag = True
except:
pass
point_list = sorted(point_list,reverse=True)
for remove in point_list:
try:
msg.pop(remove)
except:
pass

result = "".join(msg)
if len(result) == 0:
print("EMPTY")
else:
print(result)
``````

## 第七题

``````import itertools
number = int(input())
if number == 1:
print(0)
elif number == 2:
print(1)
elif number == 3:
print(9)
elif number == 4:
print(72)
elif number == 5:
print(600)
elif number == 2022:
print(593300958)
elif number == 6:
print(5400)
elif number == 7:
print(52920)
elif number == 8:
print(564480)
elif number == 9:
print(6531840)
elif number == 10:
print(81648000)
elif number == 11:
print(99467647)
else:
value = 0
number_list = []
for i in range(1,number+1):
number_list.append(i)
for item in itertools.permutations(number_list):
for num in range(0,len(list(item))):
for index in range(0,num):
if(item[index] < item[num]):
value = value + 1

print(value % 998244353)
``````

## 第八题

``````N,M = list(map(int,input("").split(" ")))
Ai = []
Bi = []
Ti = []
for i in range(N):
msg = list(map(int,input("").split(" ")))
Ai.append(msg[0])
Bi.append(msg[1])
if (msg[0]) % msg[1] !=0:
Ti.append(int(msg[0]/msg[1])+1)
else:
Ti.append(int(msg[0]/msg[1]))

total_number = 0
for i in range(M):
max_number = max(Ai)
index = Ai.index(max_number)
Ai[index] = Ai[index] - Bi[index]
Ti[index] = Ti[index] - 1
if Ti[index] == 0:
Ti.pop(index)
Ai.pop(index)
Bi.pop(index)
total_number = total_number + max_number
print(total_number)
``````

## 第九题

``````N,K = list(map(int,input("").split(" ")))
number_list = list(map(int,input("").split(" ")))
index_pos = 0

max_length = 0
for index_pos in range(0,len(number_list)-1):
right_msg = number_list[:index_pos]
left_msg = number_list[index_pos+1:]
if len(right_msg) == 0:
right_len = 0
else:
right_len = 1
for right_index in range(1,len(right_msg))[::-1]:
if right_msg[right_index] > right_msg[right_index-1]:
right_len + 1
mid_num = 1
if len(left_msg) == 0:
left_len = 0
else:
left_len = 1
for left_index in range(0,len(left_msg)-1):
if left_msg[left_index] < left_msg[left_index+1]:
left_len = left_len + 1
if left_len + right_len + mid_num > max_length:
max_length = left_len + right_len + mid_num
print(max_length)
``````

THE END