Combination number & counting problem based on number theory

                         1. Number of combinations:
Introduction to the question: Now there are n balls, take k balls among them, how many
ways are there in total?
Answer:

Intuitive explanation of the formula:
We consider taking k balls in order: the first time has n choices, the second time has n-1
choices, ..., the kth time has n-k+1 choices. Therefore, there are a
  
total of the number of solutions; but if the order is not calculated, then for a solution, there are actually k!
different orders, so dividing by k! is the final answer.
Formula required for actual programming: C(n,k) = C(n − 1,k) + C(n − 1,k − 1)
Question:
luogu 2822 Combinatorial number problem (calculating side modulo)
luogu 1313 Calculating coefficients (The answer is: an × bm × C(k,n))

 

                          2. Counting problems:
(1). How many solutions are there for dividing n numbers into k non-negative integers? C(n,k)
(2). How many solutions are there for dividing n numbers into k positive integers? C(n,n-k+1)
1. Ball placement problem:
1. Put N different balls in K different boxes-----n^k
2. N identical balls in k different boxes The box-----C(n,nk)
3. N different balls are placed in k identical boxes
4. N identical balls are placed in k identical boxes
2. Path walking:
an N*M The grid of , can only go up or to the right at a time,
how many solutions are there from the lower left corner to the upper right corner
C (n + m − 2, n − 1)

According to the lexicographical order, the sequence is given in order starting from the lowercase letter a (all strings in the sequence are ascending order strings, how many strings of length L are selected?
                

Exercise:
(1) Codevs 1262 Don't pass the ball to me
(2) HDU 5698 Teleport
(3) HDU 1465
{ Stagger
formula: Let F[i] be the number of permutations where each number is not in its own position.
* Then there is the formula F[i] = (n-1) (F[i-1] + F[i-2])
Assuming that the first position is k(k ̸= 1), there are two Case:
1 is 1 at position k. At this time, it is only necessary to require other n-2 numbers not to be in the
position.
2 is not 1 in position k. Treating 1 as k is equivalent to n-1 numbers that are not in their own
positions.
}
(4) HDU 4704 Sum

{

  

}

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325406412&siteId=291194637