This page is still under construction.

Parts of this page are still being built. What you see may change.

City

Time limit1sMemory limit256 MB

Summary
Count the segments whose endpoints and midpoint are all grid points of an (n+1) by (m+1) lattice.
Level

Medium6 of 10

Topics
Math, Number theory, Geometry, Combinatorics
Solved
No attempts yet

Problem

Hi ICPCer, welcome to Xi'an.

Xi'an is a beautiful ancient city and the capital of the Zhou, Qin, Han, and Tang Dynasties. With a long history, the streets in Xi'an follow a grid pattern.

Attracted by the structure of the streets, Coach Pang wants to conduct his research on them. He draws an n×mn\times m grid on the board. The grid consists of n+1n+1 vertical line segments and m+1m+1 horizontal line segments. The vertical and horizontal line segments intersect at exactly (n+1)×(m+1)(n+1)\times(m+1) points, forming n×mn\times m unit squares. We call the (n+1)×(m+1)(n+1)\times (m+1) intersections grid points. Output the number of line segments ll (not only vertical or horizontal) satisfying the following three conditions:

  1. The length is not zero.
  2. Both endpoints of ll are grid points.
  3. The midpoint of ll is a grid point.

Input

The only line contains two integers n,mn, m (1≤n,m≤10001\le n, m\le 1000).

Output

Print the answer in a single line.

Examples2

  1. Example 1

    Input
    1 1
    
    Expected output
    0
    
  2. Example 2

    Input
    2 3
    
    Expected output
    14