Codeforces 1312D. Count the Arrays

Codeforces 1312D. Count the Arrays

Meaning of the questions:

Calculating the number of sequences satisfying the following requirements.

  • 1: Sequence length \ (n-\) .
  • 2: sequence element is 1 ~ m.
  • 3: sequence and only a pair of numbers are equal.
  • 4: There is a sequence of cut-off point, digital cut-off point to the left of strictly monotonically increasing, monotonically decreasing digits to the right of the strict.

Data range: \ (2 \ n-Leq \ Leq m \ Leq 2E5 \) .

Take the result \ (MOD \ 998 244 353 \) .

Ideas:

First Japanese sentence, that is, when \ (n = 2 \) , the sequence does not meet the conditions, output 0.

General point of view, in order to facilitate understanding, we draw a picture.

This is a sequence of conditions is satisfied, the image to meet the crest, and only a pair of numbers are equal.

We can find, in addition to equal 4, the other numbers are different.

So we can transform it.

It as a digital pairwise disjoint increasing sequence, a sequence that satisfies such conditions how many?

We directly from \ (m \) digits selected \ (n-1 \) one out, will be the formation of such an ascending sequence, so the answer is:
\ [C_ {m} ^ {n--. 1} \]
but also there are many cases drain solutions, for example, I have two prosequence \ (1 \) , increasing sequence is obtained as shown in FIG.

Then we will find, in addition to the maximum number, all numbers can be cracked to put the right two biggest digital, so this time we want to answer multiplied by \ (the n--2 \) . as the picture shows:

The figure represents a 5 we go to the right. \ (1,2,4,5,6 \) can go to the right.

At this point is still leaking solution, we try to except (5 \) \ number other than the left to move to the right, then how many kinds of programs?

First, it \ (n-2 \) numbers among the 5 past can not be right, that is, the rest of \ (n-3 \) numbers, then the time to enumerate the number of digits to the right place, let \ ( 0,1,2,3, ..., n-3 \ ) are possible, so we have to take on the answers:
\ [{n-C_-C_. 3 + 0} ^ {^}. 1. 3-n-+ C_ {n-3} ^ 2
+ ... + C_ {n-3} ^ {n-3} = 2 ^ {n-3} \] In summary, the answer is:
\ [^ {N- C_m }. 1 \ Times (2-n-) \ Times-n-2. 3 ^ {} \]
code

Guess you like

Origin www.cnblogs.com/zxytxdy/p/12453064.html