City
Time limit1sMemory limit256 MB
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 grid on the board. The grid consists of vertical line segments and horizontal line segments. The vertical and horizontal line segments intersect at exactly points, forming unit squares. We call the intersections grid points. Output the number of line segments (not only vertical or horizontal) satisfying the following three conditions:
- The length is not zero.
- Both endpoints of are grid points.
- The midpoint of is a grid point.
Input
The only line contains two integers ().
Output
Print the answer in a single line.