Colored Paper

AtCoder
IDfps_24_f
Time2000ms
Memory256MB
Difficulty
There are $N$ sheets of paper, numbered from $1$ to $N$. Each sheet can be painted in one of three colors: red, blue, or yellow. The coloring must satisfy the following conditions: * Each sheet must be painted in exactly one color. * The number of sheets painted blue must be even. * The number of sheets painted yellow must be odd. Find the number of valid colorings that satisfy the conditions, and output the result modulo $998244353$. Two colorings are considered different if there exists at least one sheet that is painted in different colors. ## Constraints * $1 \leq N \leq 10^9$ * $N$ is an integer ## Input The input is given from standard input in the following format: $N$ [samples]
Samples
Input #1
3
Output #1
7

There are $7$ valid colorings.  
Here, $(c_1, c_2, c_3)$ means that sheet $1$ is painted in color $c_1$, sheet $2$ in $c_2$, and sheet $3$ in $c_3$.

*   (red, red, yellow)
*   (red, yellow, red)
*   (yellow, red, red)
*   (blue, blue, yellow)
*   (blue, yellow, blue)
*   (yellow, blue, blue)
*   (yellow, yellow, yellow)
Input #2
1000000000
Output #2
224965629
API Response (JSON)
{
  "problem": {
    "name": "Colored Paper",
    "description": {
      "content": "There are $N$ sheets of paper, numbered from $1$ to $N$.   Each sheet can be painted in one of three colors: red, blue, or yellow.   The coloring must satisfy the following conditions: *   Each sheet",
      "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_f"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $N$ sheets of paper, numbered from $1$ to $N$.  \nEach sheet can be painted in one of three colors: red, blue, or yellow.  \nThe coloring must satisfy the following conditions:\n\n*   Each sheet...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments