T3为什么我算出来是8: from itertools import permutations s = ['a', 'b', 'a', 'b', 'a'] child_s = [] for i in range(2, len(s), 2): for j in permutations(s, i): if(len(j) != 0): if(list(j) not in child_s): child_s.append(list(j)) count = 0 for i in child_s: for j in range(len(i)): if(i.count(i[j]) % 2 != 0): break else: if(j == len(i)-1): count = count + 1 print(int(count % (1e9+7)))
点赞 1

相关推荐

牛客网
牛客企业服务