A. City

Codeforces
IDCF10247A
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Hi ICPCer, welcome to Xi'an. Being a beautiful ancient city, Xi'an is the capital city of Zhou, Qin, Han, and Tang Dynasties. With a long history, the streets in Xi'an have a grid pattern. Attracted by the streets' structure, Coach _Pang_ would like to conduct his research on them. He draws an $n times m$ grid on the board. The grid consists $n + 1$ vertical line segments and $m + 1$ horizontal line segments. The vertical and horizontal line segments intersect at exactly $(n + 1) times (m + 1)$ points, forming $n times m$ unit squares. We call the $(n + 1) times (m + 1)$ intersections _grid point_s. Output the number of line segments(not only vertical or horizontal) $l$ satisfying the following three conditions: The only line contains two integers $n, m$($1 <= n, m <= 1000$). Print the answer in a single line. ## Input The only line contains two integers $n, m$($1 <= n, m <= 1000$). ## Output Print the answer in a single line. [samples]
**Definitions** Let $ n, m \in \mathbb{Z}^+ $ with $ 1 \leq n, m \leq 1000 $. Consider a grid with $ (n+1) \times (m+1) $ grid points, arranged in a rectangular lattice. **Objective** Count the total number of line segments $ l $ (not restricted to axis-aligned) such that: - Both endpoints of $ l $ are grid points. - The line segment connects two distinct grid points. - The segment lies entirely within the grid (i.e., no restriction on direction beyond endpoint constraints). **Formulation** The number of such line segments is the number of unordered pairs of distinct grid points: $$ \binom{(n+1)(m+1)}{2} $$
API Response (JSON)
{
  "problem": {
    "name": "A. City",
    "description": {
      "content": "Hi ICPCer, welcome to Xi'an. Being a beautiful ancient city, Xi'an is the capital city of Zhou, Qin, Han, and Tang Dynasties. With a long history, the streets in Xi'an have a grid pattern.  Attracte",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10247A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Hi ICPCer, welcome to Xi'an.\n\nBeing a beautiful ancient city, Xi'an is the capital city of Zhou, Qin, Han, and Tang Dynasties. With a long history, the streets in Xi'an have a grid pattern. \n\nAttracte...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, m \\in \\mathbb{Z}^+ $ with $ 1 \\leq n, m \\leq 1000 $.  \nConsider a grid with $ (n+1) \\times (m+1) $ grid points, arranged in a rectangular lattice.\n\n**Objective**  \nCount the...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments