[Game] [SMOJ 2019.3.17]

I need to practice what DFS TM


\(\mathrm{T1}\)

In fact, I can say it with a picture.

Untitled .png

For the red dot, it is found as the probability
\ [\ mathrm {P = 1- (1-80 \%) (1-50 \%) (1-30 \%) (1-40 \%) = 4.2 \ %} \]
(using inclusion and exclusion)

Code is very simple, tmd is DFS wrong .

\(\mathrm{Code}\)


\(\mathrm{T2}\)

First of all can be found, if the player can quite to the end, he must be able to get to each level of gold have got,

Therefore, the answer to at least \ (\ SUM \ limits_. 1 = {I}} ^ {n-VALUE_I \) .

Since then gold will be reset after death, so when we quite to the end, we only picked up left behind after the last death at a checkpoint gold .

If \ (f_i \) represents the first \ (i \) left behind after death off the expected number of gold coins, with \ (fp_i \) represents the players just died at the \ (i \) probability of closing, then the answer is equal
\ [\ sum \ limits_ {i = 1} ^ {n} (value_i + f_i \ times fp_i) \]

Next, look at the focus \ (f_i \) how demand.

In fact, very simple, you can survive the first \ (i \) off, it indicates that you must put before \ (i-1 \) off of gold coins have got, and in this former \ (i \) off you certainly only It will pick up once left lying on the floor of gold, so we just enumerate look at what you can shut picked up gold.

For convenience, you may be pretreated out \ (\ sum \ limits_ {j = 1} ^ {i} value_j \) values, with \ (sv_i \) represents

That is:
\ [I-F_i = sv_. 1} + {\ SUM \ limits_ ^ {J} = {I}. 1 F_j \ Times fp_j \]

In order to prevent their transfer, the right side of the equation we \ (f_ {k = i} \) to the left, to give
\ [f_i = \ dfrac {sv_ {i-1} + \ sum \ limits_ {j = 1} ^ {i-1} f_j \ times fp_j} {1-fp_i} \]

Then on it.

\(\mathrm{Code}\)


\(\mathrm{T3}\)

First of all can be found in \ (m \) maximum only \ (50 \) , so we can put \ (0 \ sim49 \) This \ (50 \) digits are separated out.

For each number set \ (sum_i \) represents an array of pre-pro \ (I \) number of the current request has a digital elements.

The definition of main array elements: a section \ ((l, r] \ ) has a main element if and only if:

\[sum_r-sum_l>\frac{r-l}{2}\]

It can be deduced:

\[2(sum_r-sum_l)>r-l\]

Go parentheses, move items available:

\[2sum_r-r>2sum_l-l\]

That is, for every \ (sum_r \) , if you ask them out how many \ (2sum_l-l \) satisfies the above formula can be.

This problem is not the number of range queries can be used Fenwick tree it

However, since \ (2sum_i-i \) may be less than \ (0 \) , plus about so to modify the tree when the array \ (10 ^ 5 \) offset.

\(\mathrm{Code}\)

Guess you like

Origin www.cnblogs.com/info---tion/p/11281387.html