Question 1: Energy necklace
Interval-based Dynamic Planning
It is said that this question had been plagued by many people.
F (I, j) indicates the maximum energy released by merging J beads starting from I.
F (I, j) = max {f (I, k} + f (I + k, J-k) + head (I) * head (I + k) * Head (I + J), 0 <k <j}
Boundary Condition: f (I, 1) = 0
Question 2: Jin Ming's budget plan
Backpack Dynamic Planning
01 enhanced version of the backpack, there are five options for each main component: do not buy the main component, purchase the main component, purchase the main component and accessories 1, purchase the main component and accessories 2, purchase the main component and accessories 1 and 2.
A significant time-space optimization: dividing the price of an item by 10.
Question 3: Job Scheduling Solution
Simulation
It is said that it was originally a search question, but it was simplified to balance the difficulty of the entire volume. It's not hard. Just be careful.
Question 4: 2 ^ K hexadecimal number
Recurrence, high accuracy
The first recursive formula: f (I, j) is used to represent the number of numbers starting with the number I and having J digits.
F (I, j) = sum {f (I + 1, J-1), F (I + 2, J-1 ),...}
Then the final answer is to add some f values.
Since we need sum in both state transfer and final result, we may wish to directly Save the sum of the previous State in F.
Therefore, we can use f (I, j) to represent the number of numbers whose first digit is not less than I and has J digits.
F (I, j) = f (I + 1, J) + f (I + 1, J-1)
To explain, there are two scenarios where the first digit is no less than I:
1. The first is equal to I, then the second is at least I + 1, that is, f (I + 1, J-1)
2. the first digit is greater than I, that is, the first digit is greater than or equal to I + 1, that is, f (I + 1, J ).
The final answer can be classified and discussed:
- If k | W, the answer is equal to sum {f (1, min (W/k-I, 2 ^ k-1-i), Iε[0, min (2 ^ K-1, W/K ))}
Explanation: If W can be divisible by K, the enumerated length is. We know that 2 ^ k-1 is the maximum number of digits that can be reached in one digit of 2 ^ K, and it is also the maximum number of digits of a (without other restrictions) Increasing 2 ^ K number. Therefore, min (W/K, 2 ^ k-1) is the maximum number of digits that can be reached in the current situation.
- If W mod k> 0, complete the above steps first, and then separately count the multiple incomplete ones. In this case, if the number of digits is W Div k + 1, the first digit may not be able to retrieve 1 ~ 2 ^ K-1, and can only take 1 ~ 2 ^ (W mod k)-1. Add these values.
It is not necessary to determine whether the situation may occur in all cases, because in some cases, the F value is not calculated, and it is equal to 0. For example, when k = 2, W = 6, F (1, 3) is obviously equal to 0, so even accumulating it does not affect the final result.
Noip2006 improve group question