csp-s 105 small analog magic w

This question is very personal feel of the Titans, decided to separate out to write about the solution to a problem.


Beginning he still wrong questions, and feel that this question can not be done. Then I read it again, and I'm to do, so that later do not think so.

It is easy to think of a silly × inclusion and exclusion: Subtract the total legal case situation, to get a final answer.

We count direct legal certainty is not enough to consider overlap.

Consider how we want to repeat this situation.

repeat? When we repeat the same algorithm to calculate a number of the same contribution.

When will we calculate repeat? In our calculation of the elements of the original string element appears repeat, we confuse the original series and new series, will lead to error.

First, we can have a position to contribute to s + 1 Ge is inserted empty.

How we express it this repetition?

We represented by {} string is inserted, then [........ x] {....... x} [........] and [....... .] {..........} [x ........] be repeated.

The following relation emotional understanding.

The top two strings What does it mean? . "" Represent ordinary character, x table-style "special" (that is, I want to observe repeat) character, then we will find that with the movement of the insertion section on the left is equivalent to x to the right of "squeeze" to the left. Then if the element is inserted at the beginning of a same x, then, will form the left to the right to speak in the form of double counting.

So long as we avoid this situation just fine.

It will also [........] {x ........} [x .........] and [........ X] {.......} [.........] situation?

In fact, in both cases it is the same. Interval move a move like we can still put the following in the form of transfer in the form above, then repeat the meanings vary, but in both cases equivalent, so only consider a situation just fine.

Formula: $ 26 ^ n-26 ^ {n- | s |} -25 * 26 ^ {n- | s | -1} * | s | $

 

Guess you like

Origin www.cnblogs.com/LH-Xuanluo/p/11821364.html