Python 实现【全排列】

B站影视 日本电影 2025-03-31 11:29 1

摘要:from math import factorialfrom collections import counterdef count_distinct_permutations(s):n = len(s)char_counts = Counter(s)tota

from math import factorialfrom collections import counterdef count_distinct_permutations(s):n = len(s)char_counts = Counter(s)total = factorial(n)for count in char_counts.values:total //= factorial(count)return total# 读取输入s = input.strip# 计算并输出结果print(count_distinct_permutations(s))

来源:三省生

相关推荐