Connected Graph

AtCoder
IDfps_24_m
Time2000ms
Memory256MB
Difficulty
Count the number of simple **connected** undirected graphs with $N$ vertices labeled $1$ through $N$. Output the result modulo $998244353$. ## Constraints * $1 \leq N \leq 2.5 \times 10^5$ * $N$ is an integer ## Input The input is given from standard input in the following format: $N$ [samples]
Samples
Input #1
3
Output #1
4

For $N=3$, the simple connected undirected graphs are:

*   $3$ graphs with $2$ edges,
*   $1$ graph with $3$ edges,

for a total of $4$.
Input #2
123456
Output #2
317059543
API Response (JSON)
{
  "problem": {
    "name": "Connected Graph",
    "description": {
      "content": "Count the number of simple **connected** undirected graphs with $N$ vertices labeled $1$ through $N$.   Output the result modulo $998244353$.",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "fps_24_m"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Count the number of simple **connected** undirected graphs with $N$ vertices labeled $1$ through $N$.  \nOutput the result modulo $998244353$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2.5 \\times 10^5$\n*   $...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments