Similar Arrays

AtCoder
IDcode_festival_2017_qualc_b
Time2000ms
Memory256MB
Difficulty
We will say that two integer sequences of length $N$, $x_1, x_2, ..., x_N$ and $y_1, y_2, ..., y_N$, are _similar_ when $|x_i - y_i| \leq 1$ holds for all $i$ ($1 \leq i \leq N$). In particular, any integer sequence is similar to itself. You are given an integer $N$ and an integer sequence of length $N$, $A_1, A_2, ..., A_N$. How many integer sequences $b_1, b_2, ..., b_N$ are there such that $b_1, b_2, ..., b_N$ is similar to $A$ and the product of all elements, $b_1 b_2 ... b_N$, is even? ## Constraints * $1 \leq N \leq 10$ * $1 \leq A_i \leq 100$ ## Input Input is given from Standard Input in the following format: $N$ $A_1$ $A_2$ $...$ $A_N$ [samples]
Samples
Input #1
2
2 3
Output #1
7

There are seven integer sequences that satisfy the condition:

*   $1, 2$
*   $1, 4$
*   $2, 2$
*   $2, 3$
*   $2, 4$
*   $3, 2$
*   $3, 4$
Input #2
3
3 3 3
Output #2
26
Input #3
1
100
Output #3
1
Input #4
10
90 52 56 71 44 8 13 30 57 84
Output #4
58921
API Response (JSON)
{
  "problem": {
    "name": "Similar Arrays",
    "description": {
      "content": "We will say that two integer sequences of length $N$, $x_1, x_2, ..., x_N$ and $y_1, y_2, ..., y_N$, are _similar_ when $|x_i - y_i| \\leq 1$ holds for all $i$ ($1 \\leq i \\leq N$). In particular, any i",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "code_festival_2017_qualc_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We will say that two integer sequences of length $N$, $x_1, x_2, ..., x_N$ and $y_1, y_2, ..., y_N$, are _similar_ when $|x_i - y_i| \\leq 1$ holds for all $i$ ($1 \\leq i \\leq N$).\nIn particular, any i...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments