#P11174. 「CMOI R1」Looking For Edge Of Ground/City Planning

    ID: 11875 远端评测题 2000ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>数学2024O2优化组合数学容斥原理生成函数快速傅里叶变换 FFT快速数论变换 NTT拉格朗日反演洛谷比赛

「CMOI R1」Looking For Edge Of Ground/City Planning

Background

How to count simple labeled undirected connected graphs on nn vertices?$\small\color{white}/42^{\text{nd}}\text{Problem by ArCu}.$

There is an obviously wrong method: enumerate a tree, then add edges on it.

You need to compute the sum of squares of the number of times each graph is counted.

Problem Description

Given a positive integer nn.

At first, ClBe\text{ClBe} chooses a labeled undirected unrooted tree with nn vertices, and colors the edges on the tree white. Then he adds any number of edges to this tree, with the following requirements:

  • The newly added edges are black undirected edges.
  • After adding edges, if you ignore the colors, the resulting graph is a simple graph.

Next, ClBe\text{ClBe} puts all possible results into a set SS.

Obviously, this way of counting connected graphs will count the same graph many times, so ClBe\text{ClBe} defines f(G)f(G) as follows: in SS, there are f(G)f(G) graphs whose underlying graphs (ignoring edge colors) are the same as GG (two graphs A,BA,B are the same means for any edge (u,v)(u,v), (u,v)∈A  ⟺  (u,v)∈B(u,v)\in A\iff(u,v)\in B).

(∑G\sum_G means summing over all possible graphs GG.) Obviously,

∑Gf(G)=nn−22(n−12)\sum_{G}f(G)=n^{n-2}2^\binom{n-1}2

So you need to compute

∑Gf(G)2\sum_{G}f(G)^2

Output the answer modulo 998244353998244353. Unfortunately, for some reasons, the modulus cannot be 10045358091004535809.

Input Format

One line containing one positive integer n(0<n<225)n(0<n<2^{25}).

Output Format

One line containing one integer, the answer you computed.

3
12
4
812
5
223440
107
404390093

Hint

Sample Explanation:\text{Sample Explanation}:

The set SS contains the following 66 graphs (an edge weight of 00 means a white edge, and 11 means a black edge; a vertex label like 1A1A means this is vertex 11 of graph AA):

There are 44 connected graphs on 33 vertices:

Ignoring colors,

  • The ones that are the same as GG are BB.
  • The ones that are the same as HH are AA.
  • The ones that are the same as II are CC.
  • The ones that are the same as JJ are D,E,FD,E,F.

So the answer is f(G)2+f(H)2+f(I)2+f(J)2=12+12+12+32=12f(G)^2+f(H)^2+f(I)^2+f(J)^2=1^2+1^2+1^2+3^2=12.

Details of Subtasks:\text{Details of Subtasks}:

This problem uses bundled testdata.

Subtask\text{Subtask} n<n< Score\text{Score}
11 1010 55
22 500500 2525
33 15001500 3030
44 45004500 55
55 2162^{16}
66 2172^{17}
77 2202^{20} 2020
88 2252^{25} 55

Translated by ChatGPT 5