#P4484. [BJWC2018] 最长上升子序列

    ID: 5214 远端评测题 1000ms 500MiB 尝试: 1 已通过: 0 显示难度提高+/省选− 上传者: 标签>2018北京差分杨表状压 DP

[BJWC2018] 最长上升子序列

Problem Description

Given a uniformly random permutation of length nn, compute the expected length of its longest increasing subsequence.

To avoid precision errors, you only need to output the answer modulo 998244353998244353.

Input Format

The input contains a single positive integer nn.

Output Format

Output a single non-negative integer, the remainder of the answer modulo 998244353998244353.

It can be proved that the answer is a rational number; let it be a/ba/b (a,ba, b are coprime integers). Let the integer you output be xx. You must ensure 0x<9982443530 \le x < 998244353 and abx(mod998244353)a \equiv b x \pmod{998244353}.

1

1

2

499122178

3

2

Hint

Sample #2 Explanation:

This is 3/23/2.

Constraints:

  • For 100%100\% of the data, 1n281 \le n \le 28.
  • There are 25 testcases. For the ii-th testcase (1i251 \le i \le 25), n=i+3n = i + 3.

Translated by ChatGPT 5