pythontest1
import itertools
def permutations_combinations(n, m, letters):
# 排列序列
permutations = list(itertools.permutations(letters, m))
permutation_output = [' '.join(permutation) for permutation in permutations]
# 组合序列,按字母升序排列
combinations = list(itertools.combinations(sorted(letters), m))
combination_output = [' '.join(combination) for combination in combinations]
return permutation_output, combination_output
def main():
# 获取用户输入
n, m = map(int, input().split())
letters = input().split()
# 计算排列和组合序列
perm_list, comb_list = permutations_combinations(n, m, letters)
# 输出排列序列
print("Permutation:")
for permutation in perm_list:
print(permutation)
# 输出组合序列
print("\nCombination:")
for combination in comb_list:
print(combination)
if __name__ == "__main__":
main()