用Python写成的排列问题求解代码

用python写代码果然很简练

def perm(n,m,lists): if(m == len(lists)): print ’ '.join(map(str,lists))
return 1 sum = 0 for i in range(1,n+1): if i not in lists: sum +=
perm(n,m,lists+[i]) return sum number = [int(i) for i in raw_input().split()]
perm(number[0],number[1],[])

用习惯了c/c++和java,用python的确不能得心应手…有时候不懂语言才好…