(PARI)
permcount(v)={my(m=1,s=0,k=0,t);对于(i=1,#v,t=v[i];k=if(i>1&&t==v[i-1],k+1,1);m*=t*k;s+=t);s!/m}
交叉(u,v)={和(i=1,u,和(j=1,v,gcd(u[i],v[j]))}
R(n,m,u)={if(n==0,1,sum(k=if(m==1,n,0),n\m,my(s=0);对于部分(p=k,s+=self()(n-m*k,m-1,concat(u,Vec(p))))*2^交叉(p,u)*permcount(p);s/k!)}