The problem of placing M apples on N Plates

Source: Internet
Author: User

Question 1:

M -----> same, N ---> same, can be empty

How many methods can I put M apples on N plates and leave them empty. At the same time, note that the two solutions, for example, 1, 2, 2, and 1, are one.

 

Ideas:

In fact, this is similar to dividing an integer m into the sum of N integers,

If f [m] [N] is set to the number of schemes that divide m into N portions, and the schemes are not repeated, the values of the first portion of each scheme will not be greater than those of the subsequent schemes.

F [m] [N] = f [m] [n-1] + F [M-N] [N];
= 1 // M = 0 | n = 1
= 0 // m <0

 

F [m] [n-1] is equivalent to 0 on the first plate. You only need to divide the number into n-1 portions.
Because 0 is not greater than any number, it is equivalent to adding a plate of 0 in front of the solution in F [m] [n-1,
And does not violate the definition of F. Therefore, F [m] [n-1] must be part of the f [m] [N] solution,That is, the number of solutions containing 0.
F [M-N] [N] is equivalent to adding 1 to each plate. Because adding a number 1 on each plate does not affect the feasibility of the solution in F [m] [n-1], nor does it affect the definition of F.
Therefore, F [M-N] [N] must be part of the f [m] [N] solution,That is, the number of solutions without 0.

 

 

Question 2:

Problem description: Divide integer N into the sum of K integers and each number is greater than or equal to.
Which of the following methods can be used to calculate a value less than or equal to B?

 

Int dynamics (int n, int K, int min) // divide N into k integers with the minimum value greater than or equal to Min, the maximum value is B <br/>{</P> <p> If (n <min) return 0; // when the remaining value is smaller than min, otherwise, 0 is returned. <br/> If (k = 1) return 1; <br/> int sum = 0; <br/> for (int t = min; T <= B; t ++) <br/> {<br/> sum + = dynamics (n-t, K-1, t ); <br/>}< br/> return sum; </P> <p>}

 

 

Question 3:

M -----> same, N ---> same, cannot be blank

How many methods can I put M apples on N plates. At the same time, note that the two solutions, for example, 1, 2, 2, and 1, are one.

 

Ideas:

Put each one apple first, and the problem becomes: M-N apples are put into N plates, and the plate is allowed to be empty, that is, question 1

 

 

Question 4:

The first Stirling number is positive and negative, and its absolute value isNumber of methods for dividing a set of n elements into k rings.

Recursive Formula,
S (n, 0) = 0, S (1, 1) = 1.
S (n, k) = S (n-1, k-1) + (n-1) S (n-1, K ).

 

The method for dividing a set of n elements into k rings is S (n, k ).

1. The S (n-1, k-1) of the ring can be K-1 by the first n-1 elements; that isThe last element is a single ring, and the first n-1 constitute a K-1 ring;

2. the nth element must not be a single ring. K rings of N-1 elements can place the nth number in any ring to form a new ring! N

The set of elements is divided into k rings. If the set of n elements is divided into k rings, since N is not in a single ring, you can place N in the ring where N is located.

If n-1 elements and K rings are removed, the necessity and adequacy are proved!

Therefore:S (n, k) = S (n-1, k-1) + (n-1) S (n-1, K ).Pass!

 

Question 5:

The second type of Stirling is the number of methods that divide a set containing n elements into k non-empty subsets.
// N-> there is a difference, K-> non-empty, no difference
Recursive Formula,
S (n, n) = S (n, 1) = 1,
S (n, k) = S (n-1, k-1) + KS (n-1, K ).

The above recursive formula can be proved by combination:
On the one hand, if the N element is taken out separately into a set, then the number of methods is S (n-1, k-1 );
On the other hand, if there are more than one element in the set where the nth element is located, You can first divide the remainder n-1 elements and then select another set to put the nth element in, the number of methods is K * s (n-1, k );
Evidence of the principles of Addition

 

Question 6:

Number of Bell and Stirling

B (n) is composed of n elements.Division of SetsThe number of methods.

Set Division: non-empty,

B (0) = 1, B (1) = 1,

B (n) = sum (1, N) S (n, k ).Sum (1, N) indicates the sum of K from 1 to n,

 

Question 7:

When K is different, it is generally multiplied by K's full arrangement on the basis of no difference.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.