Division of "Recursive and recursive" sets The topic description is set S is a set of n elements, S={a1,a2,......, an}, now divides s into K to meet the following conditions of a subset of S1,s2,......, SK, and satisfies:
(1) si≠∅
(2) Si∩sj=∅
(3) S1∪s2∪s3∪ ... ∪sk=s
It is called S1,s2,..., SK is a division of the set S. It is equivalent to the N elements in the s set A1,a2,..., an into K (0<k≤n<30) unlabeled box, so that no box is empty. Please make sure that n elements a1,a2,..., the number of divisions s (n,k) that go into the K-unlabeled box. Enter two integers n and k to output an integer, dividing the number of S (n,k). Sample input
4 3
Analysis: The second type of Stirling number; (one of the ball box models)
Code:
#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>#include<climits>#include<cstring>#include<string>#include<Set>#include<map>#include<queue>#include<stack>#include<vector>#include<list>#defineRep (I,m,n) for (i=m;i<=n;i++)#defineRSP (It,s) for (Set<int>::iterator It=s.begin (); It!=s.end (); it++)#defineMoD 1000000007#defineINF 0x3f3f3f3f#defineVI vector<int>#definePB Push_back#defineMP Make_pair#defineFi first#defineSe Second#definell Long Long#definePi ACOs (-1.0)Const intmaxn=1e4+Ten;Const intdis[][2]={0,1,-1,0,0,-1,1,0};using namespacestd;ll gcd (ll p,ll q) {returnq==0? P:GCD (q,p%q);} ll Qpow (ll p,ll q) {ll F=1; while(q) {if(q&1) f=f*p%mod;p=p*p%mod;q>>=1;}returnF;}intDfsintXinty) { if(x<y| | y==0)return 0; Else if(y==1|| X==y)return 1; Else returnDFS (X-1, Y1) +y*dfs (x1, y);}intMain () {inti,j,m,n,k,t; scanf ("%d%d",&n,&m); cout<<dfs (n,m) <<Endl; //System ("pause"); return 0;}
Division of "Recursive and recursive" sets