import copy a = input() array = list(map(int,raw_input().split())) empty_list = [] empty_list1 = [] count = 0 def full_arrange(n):     data = []     res = []     if n==1:         return 1     res = [[1]]     for i in range(2,n+1):         for j in range(len(res)):             for x in range(len(res[j])+1):                 data = copy.copy(res[j])                 data.insert(x,i)                 res.append(data)                 x += 1             j += 1         while True:             if len(res[0]) != i:                 res.remove(res[0])             else:                 break         i += 1     return res #print(full_arrange(3)) possible = full_arrange(a) def solution(x):     for i in range(len(x)-1):         if x[i] > x[i+1]:             m = 1             empty_list.append(m)         if x[i] <x[i+1]:             m = 0             empty_list.append(m)     return (empty_list) for i in possible:     empty_list1.append(solution(i)) print(empty_list1) for i in range(len(empty_list1)):     if array == empty_list1[i]:         count = count+1 print(count) 第二题答案,每次都是马后炮,因为一个小细节没通过,考完了五分钟就解决了😣
点赞 6

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务