"Brush title" poor and STS

Is a false expectation, we found a total of $ C_ {2n} ^ m $ case.

而$ \frac{(2n)!}{m!(2n-m)!}=C_{2n}^m $

In fact, the result is that each case of the total damage.

1.10 points algorithm, burst search 10 points.

2.30 points algorithm and found that 20% of the same brand value of attack, so to strengthen the attack (attack at least leave a card) is the best strategy. I got the calculation sheets strengthened cards, the minimum is to strengthen the product and the size can be multiplied by the attack cards under $ j $ Zhang's case.

3.50 points algorithm and found that 20% of the $ m == k $, so regardless of the brand strategy, to strengthen the attack can be, i got were calculated Zhang strengthen the brand, the minimum is to strengthen the product in the case of the j-th frame and the and i get attacked Zhang cards, is a minimum in case of attack and the j Zhang. By multiplying the two parts separately.

4.AC algorithm, the optimal strategy considering general solution. Each was found to strengthen the brand will at least double the value of all the attack cards, so if I choose to play only the biggest attack a card, even if the card is a minimum of strengthening the cards occupy an opportunity, but also can make the greatest a double, this contribution is greater than the maximum attack hit a card and a second major attack cards. That is the position for each position, the minimum contribution should be to strengthen the brand of attack is greater than the second largest brand, then the optimal strategy is to only play a maximum of attacks card, leave the rest to strengthen the brand from the big small hit, and finally play this card attack, this is the greatest harm.

With After this decision, we wish to sort deck.

Set $ ​​f [i] [j] $ i chose to strengthen the brand Zhang, the last one is the smallest of the election is the product of a j-outs and, $ g [i] [j] $ chose to attack cards $ i $ Zhang, the last one is the smallest of the election is a j-card attacks and, $ a_i $ are the $ i $ Zhang strengthen the brand, $ b_i $ $ i $ Zhang is the first attack cards.

Initialization: $ f [0] [0] = 1 $;

equation:

  $ f[i][j]=a_i\sum \limits_{k=1}^{j-1} f[i-1][k] $

  $ g[i][j]=b_i C_j-1^i-1 \sum \limits_{k=1}^{j-1} g[i-1][k] $

Means a combination of numbers until there is such a variety of circumstances (j-1 i-1 card select cards, in each case transferred to the g [i] [j] are necessary to add a B_i), prefix and optimization, are $ O (n ^ 2) $

Provided $ F [i] [j] $ is selected from $ I $ sheets reinforced cards played $ J $ sheets reinforced card product sum, $ G [i] [j] $ is selected from $ I $ sheets attack cards, played $ j $ Zhang attacking brand of injury and.

equation:

  $ F[i][j]=\sum \limits_{k=j}^n f[j][k] C_{n-k}^{i-j} $

  $ G[i][j]=\sum \limits_{k=j}^n g[j][k] C_{n-k}^{i-j} $

This combination means that the number of j cards is my big break out, the remaining $ ij $ Zhang's certainly not as good as before the $ j $ Zhang excellent, which is less than $ k $, and less than k cards a total of $ nk $ Zhang.

This finding is $ O (n ^ 3) $ can not afford the time, observing the answer.

Our requirements:

    $ ans=\sum \limits_{i=0}^{min(m-1,n)} F[i][min(i,k-1)] G[m-i][max(1,k-i)] $

It was developed based on the optimal strategy, that is to say i Zhang strengthen the brand to do more than hit $ k-1 $ Zhang, and $ mi $ Zhang attack cards to play a minimum.

We have found function $ F $ $ G $ function and have taken a single point value, so need only count up to $ m $ values.

Then the computational complexity and $ F $ remains of $ G $ $ O (n ^ 2) $

The total time complexity: $ O (Tn ^ 2) $

Problems have solutions.

Guess you like

Origin www.cnblogs.com/Lrefrain/p/11234687.html