题目大意:给定n个男生m个女生两个老师,求有多少种排列满足任意两个女生不相邻,任意两个老师也不相邻
def A(n): re=1 for i in range(1,n+1): re*=i return re def C(n,m): if n<m: return 0 return A(n)//A(m)//A(n-m) n,m=[int(i) for i in raw_input().split()] print m*A(n+1)*2*A(m-1)*C(n+2,m-1)+(A(n+2)-A(n+1)*2)*A(m)*C(n+3,m)
原文地址:http://blog.csdn.net/popoqqq/article/details/42964171