disjointQ[u_]:=应用[And,Outer[#1==#2||交集[#1,#2]=={}&,u,u,1],{0,1}];
sps[{}]:={{}};sps[set:{i_,___}]:=Join@@Function[s,Prepend[#,s]和/@sps[Complement[set,s]]/@Cases[Subset[set],{i,___}];
mps[set_]:=联合[Sort[Sort/@(#/.x_Integer:>set[[x]])]&/@sps[Range[Length[set]]];
gro[m_]:=gro[m]=如果[Length[m]==1,{m},选择[Union[Sort/@Join@@(Tuples[gro/@#]&/@Select[mps[m],Length[#]>1&])],disjointQ]];
表[Sum[Length[gro[m]],{m,Flatten[MapIndexed[Table[#2,{#1}]&,#]]&/@Integer Partitions[n]}],{n,5}]
|