这个题就是将字符串转成列表,调用一下sort方法 就行了
s = "WHERETHEREISAWILLTHEREISAWAY" arr = [] for i in s: arr.append(i)
arr.sort() for i in arr: print(i, end="")

第二题,暴力破解,没解出来。。。。

 

这个题,就是把短边变长边,长边除以2就好了
import math s = input() num = int(s.split("A")[1]) A0 = [1189, 841] tmp =
A0.copy() for i in range(num): tmp = [tmp[1], math.floor(float(tmp[0]) / 2.0)]
print(tmp[0]) print(tmp[1])

思路是先求出所有位数之和,然后将当前值,还有位数之和存入一个列表,遍历这个列表,依次比较就好了, 
n = int(input()) m = int(input()) arr = [[1, 1]] def get_sum(num): m = 0 s =
10 while True: if num == 0: break m += num % s num = num // s return m for i in
range(2, n + 1): x = get_sum(i) flag = False tmp = arr.copy() for j, v in
enumerate(arr): if x < v[0]: tmp.insert(j, [x, i]) flag = True break elif x ==
v[0]: if i < v[1]: tmp.insert(j, [x, i]) flag = True break if not flag:
tmp.append([x, i]) arr = tmp.copy() print(arr[m - 1][1])

这个题,不会做。。。

 这个题,我觉得就是每次先找出来边缘字符,然后将边缘字符的索引存入一个列表,然后根据这个列表去删除边缘字符,然后不断循环,直到为空,或者一次循环没有变化为止
s = input() arr = [] for i in s: arr.append(i) tmp = set() i = pow(2, 64)
while True: for i in range(len(arr)): if i + 1 < len(arr) and i - 1 >= 0 and
arr[i - 1] == arr[i] and arr[i] != arr[i + 1]: tmp.add(i) tmp.add(i + 1) elif i
+ 1 < len(arr) and i - 1 >= 0 and arr[i] == arr[i + 1] and arr[i - 1] !=
arr[i]: tmp.add(i - 1) tmp.add(i) count = 0 if tmp == set(): break while tmp !=
set(): v = tmp.pop() arr.pop(v - count) count += 1 tmp.clear() if arr == []:
break if i == 0: break i = i - 1 if arr == []: print("EMPTY") else: for i in
arr: print(i, end="")
 

 这个题我用的笨方法,先用itertools 里面的方法,把全部全排列求出来,然后遍历全排列,然后求解,也不确定对不对
import itertools n = int(input()) t = [i + 1 for i in range(n)] arr =
list(itertools.permutations(t)) count = 0 for i in arr: for j in range(1,
len(i)): for k in range(0, j): if i[k] < i[j]: count += 1 print(count %
998244353)

这个题也不确定,我的思路是每一次都找出来最大的那一个升级。
string = input() arr = string.split(" ") N, M = int(arr[0]), int(arr[1]) alls
= [] for i in range(N): str1 = input().split(" ") tmp = [] for j in str1:
tmp.append(int(j)) alls.append(tmp) s = 0 while True: x = {"m": 0, "index": 0}
tmp = x["m"] for i in range(len(alls)): t = alls[i][0] if t > x["m"]: x["m"] =
alls[i][0] x["index"] = i if x["m"] < tmp: break s += x["m"]
alls[x["index"]][0] -= alls[x["index"]][1] M -= 1 if M == 0: break print(s)
 

这个题,不会做。。。。

 

这个题,也不会做。。蒙上了
str1 = input() nums = [int(i) for i in str1.split(" ")] n = nums[0] k =
nums[1] string = input() strs = string.split(" ") arr = [int(i) for i in strs]
count = 0 for i in range(len(arr)): if k > 0: while True: if arr[i] == 0: break
flag = True if k + i < len(arr) + 1: for j in range(i, k + i): if arr[j] < 0:
flag = False if flag and k + i < len(arr) + 1: for j in range(i, k + i): arr[j]
-= 1 count += 1 else: while True: arr[i] -= 1 count += 1 if arr[i] == 0: break
else: while True: if arr[i] == 0: break arr[i] -= 1 count += 1 print(count)
 

技术
©2019-2020 Toolsou All rights reserved,
C语言——qsort函数CSS实现溢出显示省略号网络层协议——ICMP协议C语言小游戏-俄罗斯方块Qt入门教程【基础控件篇】QCalendarWidget日历控件用python来控制wifi连接vue中input框只能输入数字Python内置函数C语言数据结构-顺序表删除重复V2.0.0abaqus质量缩放系数取值_ABAQUS的质量缩放