Mathematics (2) noip Review - The recurrence relations

1. Question one: rabbit breeding (Feibolaqi number of columns)

​ f[n]=f[n-1]+f[n-2]

\[ Fibonacci:f(n)=\frac{1}{\sqrt{5}}\left(\frac{1+\sqrt{5}}{2}\right)^n-\frac{1}{\sqrt{5}}\left(\frac{1-\sqrt{5}}{2}\right)^n \]

Second problem: Convex Triangulation / brackets Problem / a different number of problems / issues stack binary number sequence (number Cattleya)

f[n]=f[2]f[n-1]+f[3]f[n-2]+...+f[n-1]f[2]=f[n-1](4*n-2)/(n+1)

\[ Catlan:f(n)=\frac{\left(2*n\right)!}{n!*\left(n+1\right)!} \]

Question three: Matches. With n (1 <= n <= 2000) matchsticks number can be non-negative integers

Analysis: Let C [x] represents the number of matches required number x (0 <= x <= 9 ), with f [i] to update f [i + c [x] ] ( the latter corresponding to the number of plus this number x), when i is equal to 0 is not allowed when the number 0 , but when n> = 6, 1 is added to the answer alone, represents an integer of 0.

d[i+c[x]]+=d[i];

Question four: and the number of cubic meters.

Enter a positive integer n (n <= 1e4), you will find many kinds of programs written in a plurality of n positive integers and have the cube. There are three kinds of writing such as 21, 77 there are 22 kinds of writing, there are 9999 species of writing 440,022,018,293

Analysis: establish a multi-segment map. Arranged nodes (i, J) indicating "no more than the size of a cubic integer i, the cumulative sum of J" in this state, let d (i, j) from (0,0) to (i, J) the path number of, the final answer is d (21, n) (because 21 is ^. 3> n-)
\ [D [I] [J + a * I * I * I] + = D [I-. 1] [ J] \]
but may also be further optimized:
\ [D [I] [J] + = D [I] [I * I * JI] (entirely similar to the backpack) \]

Question 5: Villagers line up.

The village now has n individual (1 <= n <= 40,000) people, how many ways can put them in a row, so that no one is standing in front of his father (the father of some people may not be inside the village), total output the digital to analog program 1e9 + 7

Question six: with reference to FIG communication count.

Statistics have n (n <= 50) communicating FIG how many vertices. FIG vertices numbered.

Analysis: without considering the case of communication, when the n Labeled point total can form
\ [h (n) = 2
^ {\ frac {n (n-1)} {2}} \] Photo ( considering both the edges between any two points, the total of (n-1) + (n -2) + ... + 1 = n (n-1) / 2 edges, and each edge, or even have the choice is not connected, it is 2 ^ (n (n-1 ) / 2) species graph f (n) we set the communication, the communication is not shared FIG g (n) sheets, then f (n) + g (n) = h (n) .

g (n) can be calculated as: where is provided a communication component has k points, there are C (n-1, k- 1) case. After determining the set of points, one where the connected components have f (n) case, while the other connected components have h (nk) case, then:
\ [G (n-) = \ sum_ {K = 1} ^ {n--1 } C (n-1, k
-1) * f (k) * h (nk) \] after each calculation of g (n), should be immediately calculated f (n) and h (n).

Guess you like

Origin www.cnblogs.com/iwillenter-top1/p/11616130.html