Hanjo

AtCoder
IDabc196_d
Time2000ms
Memory256MB
Difficulty
We have a rectangular room that is $H$ meters long and $W$ meters wide. We will cover this room with $A$ indistinguishable $2$ meters $\times$ $1$ meters rectangular tatami mats and $B$ indistinguishable $1$ meter $\times$ $1$ meter square tatami mats. The rectangular mats can be used in either direction: they can be $2$ meters long and $1$ meter wide, or $1$ meter long and $2$ meters wide. How many ways are there to do this? Here, it is guaranteed that $2A + B = HW$, and two ways are distinguished if they match only after rotation, reflection, or both. ## Constraints * All values in input are integers. * $1 ≤ H, W$ * $HW ≤ 16$ * $0 ≤ A, B$ * $2A + B = HW$ ## Input Input is given from Standard Input in the following format: $H$ $W$ $A$ $B$ [samples]
Samples
Input #1
2 2 1 2
Output #1
4

There are four ways as follows:
![image](https://img.atcoder.jp/ghi/d01b63c75c91bd87a73e9a4cc43dda28.png)
Input #2
3 3 4 1
Output #2
18

There are six ways as follows, and their rotations.
![image](https://img.atcoder.jp/ghi/b7a492abe22e30683e8f9a7b309acd52.png)
Input #3
4 4 8 0
Output #3
36
API Response (JSON)
{
  "problem": {
    "name": "Hanjo",
    "description": {
      "content": "We have a rectangular room that is $H$ meters long and $W$ meters wide.   We will cover this room with $A$ indistinguishable $2$ meters $\\times$ $1$ meters rectangular tatami mats and $B$ indistinguis",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc196_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have a rectangular room that is $H$ meters long and $W$ meters wide.  \nWe will cover this room with $A$ indistinguishable $2$ meters $\\times$ $1$ meters rectangular tatami mats and $B$ indistinguis...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments