#P10562. Triangle Square Count

    ID: 12583 Type: Default 1000ms 256MiB

Triangle Square Count

Triangle Square Count

Given three points \(A(a, 0)\), \(B(0, b)\), and \(C(0, 0)\) in the plane, the triangle \(ABC\) is formed. A grid square is defined by its four vertices at \((x, y)\), \((x+1, y)\), \((x, y+1)\), and \((x+1, y+1)\) for integers \(x\) and \(y\). A square is considered to belong to the triangle if at least half of its area is inside the triangle.

Your task is to compute the size of triangle \(ABC\), which is defined as the number of grid squares that belong to it.

The triangle has vertices \(A(a, 0)\), \(B(0, b)\), and \(C(0, 0)\). It can be shown that the answer is \(\lceil \frac{a \times b}{2} \rceil\), where \(\lceil x \rceil\) denotes the ceiling function.

For example, when \(a = 8\) and \(b = 6\), the triangle covers exactly 24 squares.

inputFormat

The input consists of a single line containing two positive integers \(a\) and \(b\) separated by a space.

outputFormat

Output a single integer, the number of grid squares that belong to the triangle \(ABC\), where a grid square is counted if at least half of it is inside the triangle.

sample

8 6
24