Under construction

Still being built. Things may change

I Love Geometry

Interview

Time limit3sMemory limit1024 MB

Summary
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 NN and height MM. 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 (x,y)(x, y) with 0≤x≤N0 \leq x \leq N and 0≤y≤M0 \leq y \leq M. 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 NN and height MM of the yard. (1≤N,M≤101 \leq N, M \leq 10)

출력

Print the number of fence shapes that can be built.

Examples3

  1. Example 1

    Input
    1 1
    
    Expected output
    1
    
  2. Example 2

    Input
    2 1
    
    Expected output
    4
    
  3. Example 3

    Input
    2 2
    
    Expected output
    8