Bishop

AtCoder
IDpanasonic2020_b
Time2000ms
Memory256MB
Difficulty
We have a board with $H$ horizontal rows and $W$ vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the $r_1$\-th row (from the top) and the $c_1$\-th column (from the left) to the square at the $r_2$\-th row and the $c_2$\-th column if and only if exactly one of the following holds: * $r_1 + c_1 = r_2 + c_2$ * $r_1 - c_1 = r_2 - c_2$ For example, in the following figure, the bishop can move to any of the red squares in one move: ![image](https://img.atcoder.jp/panasonic2020/943f3f8428e6f8328924ff99681c932b.png) ## Constraints * $1 \leq H, W \leq 10^9$ * All values in input are integers. ## Input Input is given from Standard Input in the following format: $H \ W$ [samples]
Samples
Input #1
4 5
Output #1
10

The bishop can reach the cyan squares in the following figure:
![image](https://img.atcoder.jp/panasonic2020/b218e01560fe6e40e7d082ca57a64e6e.png)
Input #2
7 3
Output #2
11

The bishop can reach the cyan squares in the following figure:
![image](https://img.atcoder.jp/panasonic2020/088830f8a244d99a9f95d20bf9a8d336.png)
Input #3
1000000000 1000000000
Output #3
500000000000000000
API Response (JSON)
{
  "problem": {
    "name": "Bishop",
    "description": {
      "content": "We have a board with $H$ horizontal rows and $W$ vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "panasonic2020_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "We have a board with $H$ horizontal rows and $W$ vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?\n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments