Current location - Training Enrollment Network - Mathematics courses - Mathematical division problem
Mathematical division problem
wrong

# include & ltcstdio & gt? # include & ltiostream & gt? # include & lt string & gt? Use? Namespace? std? int? n; ? int? ans[ 10]; ? int? Used [10]; ? Invalid? perm(int? k){? int? I,j; ? if(k==n){? for(I = 0; I<n-1; i++)? cout & lt& ltans[I]& lt; & lt"?" ; ? cout & lt& ltans[I]& lt; & ltendl? Return? ; ? }? for(I = 0; I & ltn;; i++){? If (used [i]==0)? { ans[k]= I+ 1; Used [I] =1; }? Or what? {Continue; }? Perm (k+1); ? ans[k]= 0; ? Used [i] = 0; ? }? }? int? main()? {? CIN & gt; & gtn; ? Perm (0); ? Return? 0; ? Let the set of n elements be divided into F(n, m) different sets composed of m non-empty subsets.

Consider a set of three elements, which can be divided into

① Set of1subset: {{ 1, 2,3}}

② Set of two subsets: {{ 1, 2}, {3}}, {{ 1, 3}, {2}}, {{2,3}, {1}}

③ Set of three subsets: {{ 1}, {2}, {3}}

∴f(3, 1)= 1; F(3,2)= 3; F(3,3)= 1;

What if f (4,2) is needed?

A. Add the element {4} to ① to get {{ 1, 2,3}, {4}}

B. Add 4 to any subset in ② to get

{{ 1,2,4},{3}},{{ 1,2},{3,4}},

{{ 1,3,4},{2}},{{ 1,3},{2,4}},

{{2,3,4},{ 1}},{{2,3},{ 1,4}}

∴f(4,2)=f(3, 1)+2*f(3,2)= 1+2*3=7

Generalization, f (n, m) = f (n- 1, m- 1)+m * f (n- 1, m).

The answer is 90.