[ICPC 2024 Xi'an I] Triangle

Luogu
IDLGP10562
Time1000ms
Memory512MB
DifficultyP3
2024O2优化ICPC西安
There are three points $A(a, 0)$, $B(0, b)$, $C(0, 0)$ in the plane rectangular coordinate system. Define the size of triangle $ABC$ as the number of squares that belong to it. For integers $x,y$, one square is defined by four points $(x, y)$, $(x + 1, y)$, $(x, y + 1)$, $(x + 1, y + 1)$. We consider a square to belong to a triangle if half or more of it is inside the triangle. For example, when $a = 8, b = 6$, the size of triangle $ABC$ will be $24$. The image below shows which squares are counted in the triangle. ![](https://cdn.luogu.com.cn/upload/image_hosting/3fnqi74y.png) ## Input The first and only line contains two integers $a\ (1\le a\le 10^6)$ and $b\ (1\le b\le 10^6)$. ## Output Print an integer: the size of triangle $ABC$. [samples]
Samples
Input #1
6 8
Output #1
24
Input #2
5 5
Output #2
15
Input #3
1 999999
Output #3
500000
API Response (JSON)
{
  "problem": {
    "name": "[ICPC 2024 Xi'an I] Triangle",
    "description": {
      "content": "There are three points $A(a, 0)$, $B(0, b)$, $C(0, 0)$ in the plane rectangular coordinate system. Define the size of triangle $ABC$ as the number of squares that belong to it.                For inte",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 524288
    },
    "difficulty": {
      "LuoguStyle": "P3"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP10562"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are three points $A(a, 0)$, $B(0, b)$, $C(0, 0)$ in the plane rectangular coordinate system. Define the size of triangle $ABC$ as the number of squares that belong to it.\n    \n    \n    \nFor inte...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments