Poj 3014 Cake Pieces and Plates integer splitting
Question:
Split m into n numbers, and a certain number is allowed to be 0. Calculate the number of split schemes.
Analysis:
Let's split the naked integer. h (m, n) indicates splitting m into n numbers. A number of 0 schemes are allowed. For the recursive equation, see the code. Interestingly, in the previous post titled poj1221, if f (m, n) is set, the number of m parts cannot be split by an integer of 0, h (m, n) = f (m, n ).... Solve these meanings...
Code:
// Poj 3014 // sep9 # include
Using namespace std; const int maxN = 4500; const int mod = 1000000007; int a [maxN + 10] [maxN + 10]; int main () {int m, n; scanf ("% d", & n, & m); for (int I = 1; I <= m; ++ I) for (int j = 1; j <= n; ++ j) {if (I = 1 | j = 1) a [I] [j] = 1; else if (j> I) a [I] [j] = a [I] [I]; else if (j = I) a [I] [j] = a [I] [J-1] + 1; else {a [I] [j] = (a [I] [J-1] + a [I-j] [j]); if (a [I] [j]> = mod) a [I] [j]-= mod;} printf ("% d \ n ", a [m] [n] % mod); return 0 ;}