<> First question

The dog nodded at the question , Send sub questions , Direct loss of code
#coding=utf-8 msg = input() print("".join(sorted(msg)))
After running, the results will come out .

<> Second question :

I really don't know the Chinese remainder theorem ,, since it is so , Let's play in the violence cup .
#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)
I firmly believe , Just stick to it , There are no problems that cannot be solved !!!!
Although I'm sorry , I didn't get the right answer in four hours ....

<> Question 3

The only thing to pay attention to in this problem is to fold only the long side in half , Relatively simple , Direct release code , Hand it back and do it ,7 Recursion is nothing :
#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))
<> Question 4


This problem is to sum the numbers , again python in , Convert to list and call directly sum Function , A queue is then used to temporarily store digital information , Comparison finished sum Insert queue after and , Finally, return the result pointed to by the corresponding subscript of the queue .
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
indexin 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])
<> Question 5

Should be DFS, Didn't look carefully , Just jump , There's no time to do it later . A maze problem , Recursive solvable .

<> Question 6

This question is to compare i Point to the following table if two are the same , Then the different and adjacent characters that are the same should be deleted as edge characters .

Here's the idea python One is used in point_list Stores the subscript of the list of numbers to be deleted , When we find all the edge characters in a round , Then delete the in the character point_list Delete elements from back to front .
From back to front is to prevent the deletion of the previous element from leading to the confusion of the following subscripts , One sorted It's just a function -_- The code is as follows , Add one try……except Just in case
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)
<> Question 7


No good optimization ideas , It's a little heavy , use python of itertools The module must have timed out , I didn't think about it , Still used itertools The full permutation function of the module to help solve the problem , But I still got too few points .
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)
<> Question 8

Personally, it's not difficult , But I don't know if there is a pit , The idea is greedy , Find the optimal solution every time .
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)
<> Question 9

Violence cup , Nothing is two for Circulation can't solve it , If so , Just three .
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_indexin 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_numprint(max_length)
<> Question 10

I was stupid during the game ,,, Thought the title was wrong , After the match, I found that I lost by mistake ..... This wave of blood loss , But let's see some problems , I've been working on cloud primitives lately , There's really no time to adjust the algorithm .

Technology
Daily Recommendation
views 267
views 232
views 231