思路:
考虑 把男生排成一排 女生和老师往里插 分成两种情况. 1. 女生中间夹着老师 2. 女生中间没有夹着老师求一下组合* 阶乘就好了
先放Python代码 简洁易懂def fact(n): temp=1 for i in range(1,n+1): temp*=i return tempdef C(n,m): if(n
高精写挂了好几次… 尴尬
//By SiriusRen#include#include #include using namespace std;struct Node{ void init(){memset(a,0,sizeof(a));len=0;} int a[20050],len;}fst,N_plus_one,N_plus_two,N_plus_three,M,M_minus_one,C1,C2,ans;int n,m;Node operator*(Node a,int b){ for(int i=0;i =0;i--){ temp=temp*10+a.a[i]; a.a[i]=temp/b,temp=temp%b; } for(int i=a.len-1;~i;i--){ if(a.a[i]){a.len=i+1;break;} else if(!i)a.len=0; } return a;}Node operator*(Node a,Node b){ Node c;c.init(); for(int i=0;i