#P4484. Expected Length of Longest Increasing Subsequence

    ID: 17730 Type: Default 1000ms 256MiB

Expected Length of Longest Increasing Subsequence

Expected Length of Longest Increasing Subsequence

Given a random permutation of length nn, compute the expected value of the length of its longest increasing subsequence (LIS). Formally, let $$E = \frac{1}{n!}\sum_{\pi \in S_n} \mathrm{LIS}(\pi),$$ where SnS_n is the set of all permutations of {1,2,,n}\{1,2,\dots,n\}. To avoid issues with precision, output the value of EE modulo 998244353998244353.

Note: In this problem, nn is small (for example, 1n81 \le n \le 8) so that it is feasible to iterate over all permutations.

inputFormat

Input consists of a single line containing one integer nn (1n81\le n\le 8), representing the length of the permutation.

outputFormat

Output a single integer — the expected length of the longest increasing subsequence modulo 998244353998244353.

sample

1
1