解题思路:
就是直接模拟题目
注意事项:
只过了一个,其他内存超限 放这里也是想听大伙的意见
参考代码:
from itertools import permutations n = int(input()) list1 = [] a = 1 for i in range(n): list1.append(a) a += 1 list2 = [] list2.extend(permutations(list1, n)) cnt = 0 if len(list2) == 1: cnt = 0 else: for i in list2: for j in range(1, len(i)): for k in range(j): if i[k] < i[j]: cnt += 1 print(cnt)
0.0分
1 人评分