I Love Geometry
InterviewTime limit3sMemory limit1024 MB
Count the non-degenerate triangles with lattice-point vertices in an N by M yard, where triangles that match after rotation or reflection count once.
- Level
Medium4 of 10
- Topics
- Brute force, Geometry, Hash map
- Solved
- No attempts yet
문제
Seongwoo, who loves geometry, bought a rectangular yard with width and height . Since Seongwoo especially likes triangles, Seongwoo wants to build a triangular fence in this yard. The coordinates of the fence's vertices must always be integers, and no part of the fence may go outside the yard. The fence may touch the border of the yard.
In other words, the three vertices of the fence must each be placed at integer coordinates with and . Seongwoo wants to know how many different fence shapes can be built. Help Seongwoo find this number!
Two triangles (fence shapes) are considered the same if one can be rotated or flipped to match the other.
입력
The first line contains the width and height of the yard. ()
출력
Print the number of fence shapes that can be built.