luogu#P4841. [集训队作业2013] 城市规划

    ID: 3730 远端评测题 2000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数学2013集训队互测生成函数快速傅里叶变换 FFT快速数论变换 NTT

[集训队作业2013] 城市规划

Problem Description

After just solving the problem of the power network, Ali is stuck again by a task from his leader.

As mentioned before, Ali’s country has nn cities. Now the country needs to build some trade routes between certain pairs of cities, so that any two cities in the whole country are connected directly or indirectly.

To save money, there can be at most one direct trade route between every pair of cities. For two route-building plans, if there exists a pair of cities such that whether a route is built between them is different in the two plans, then the two plans are different; otherwise, they are the same. Now you need to find how many different plans there are in total.

That is the problem troubling Ali. In other words, you need to count the number of simple (no multiple edges and no self-loops) labeled undirected connected graphs on nn vertices.

Since this number may be very large, you only need to output the number of plans modulo 10045358091004535809 ( 479×221+1479 \times 2 ^{21} + 1 ).

Input Format

Only one line containing one integer nn.

Output Format

Only one line containing one integer, the number of plans mod 1004535809\bmod \space 1004535809.

3
4
4
38
100000
829847355

Hint

Constraints
For 20%20\% of the testdata, n10n \le 10.
For 40%40\% of the testdata, n1000n \le 1000.
For 60%60\% of the testdata, n30000n \le 30000.
For 80%80\% of the testdata, n60000n \le 60000.
For 100%100\% of the testdata, n130000n \le 130000.

Source: the second homework of China CTT in 20132013.

Translated by ChatGPT 5