Ex - Diff Adjacent

AtCoder
IDabc297_h
Time4000ms
Memory256MB
Difficulty
A positive-integer sequence is said to be **splendid** if no two adjacent elements are equal. Find the sum, modulo $998244353$, of the lengths of all splendid sequences whose elements have a sum of $N$. ## Constraints * $1 \le N \le 2 \times 10^5$ * All values in the input are integers. ## Input The input is given from Standard Input in the following format: $N$ [samples]
Samples
Input #1
4
Output #1
8

There are four splendid sequences whose sum is $4$: $(4),(1,3),(3,1),(1,2,1)$. Thus, the answer is the sum of their lengths: $1+2+2+3=8$.
$(2,2)$ and $(1,1,2)$ also have a sum of $4$ but ineligible because their $1$\-st and $2$\-nd elements are the same.
Input #2
297
Output #2
475867236
Input #3
123456
Output #3
771773807
API Response (JSON)
{
  "problem": {
    "name": "Ex - Diff Adjacent",
    "description": {
      "content": "A positive-integer sequence is said to be **splendid** if no two adjacent elements are equal. Find the sum, modulo $998244353$, of the lengths of all splendid sequences whose elements have a sum of $N",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc297_h"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A positive-integer sequence is said to be **splendid** if no two adjacent elements are equal.\nFind the sum, modulo $998244353$, of the lengths of all splendid sequences whose elements have a sum of $N...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments