loj#P552. 「LibreOJ Round #8」MIN&MAX I

    ID: 15258 传统题 1000ms 256MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>数学多项式 / 形式幂级数DFT(含 NTT)及FFT图论概率与期望组合计数LibreOJ Round

「LibreOJ Round #8」MIN&MAX I

Description

For an nn-order permutation pp, we set up an undirected simple graph G(p)G(p) with nn vertices numbered from 11 to nn. We create an edge between each vertice ii and the nearest vertices in each side which correspond a greater (or less) pp value than pip_i.
Formally,in this graph, u<v\forall u<v, the edge (u,v)(u, v) exists iff at least one of the following four conditions hold:

  • pu<pvp_u<p_v, and no u<i<vu<i<v exists such that pu<pip_u<p_i;
  • pu>pvp_u>p_v, and no u<i<vu<i<v exists such that pu>pip_u>p_i;
  • pu<pvp_u<p_v, and no u<i<vu<i<v exists such that pi<pvp_i<p_v;
  • pu>pvp_u>p_v, and no u<i<vu<i<v exists such that pi>pvp_i>p_v.

Now we randomly choose a permutation pp from all nn-order permutations. Your task is to calculate the expected number of the 33-cycles in G(p)G(p). You only need to output the answer modulo 998244353998244353.

Input Format

The only line contains a positive integer nn which means the order of the permutation.

Output Format

Output only one line,which contains an integer ans\mathrm{ans} which means the expected number of the 33-cycles in G(p)G(p) modulo 998244353998244353.

3
665496236
91
116578319
3
665496236
91
116578319

Constraints

For all test cases, 1n<9982443531\le n<998244353.

Detailed constraints are as follows (blank grids denote the same constraints as mentioned above):

Subtask # Score (percentage) nn
11 1515 10\le 10
22 2020 100\le 100
33 4040 106\le 10^6
44 1515 998000000\ge 998000000
55 1010 -