#P14738. [ICPC 2021 Seoul R] Grid Triangle

[ICPC 2021 Seoul R] Grid Triangle

题目描述

A grid triangle in the 3-dimensional grid system is a triangle of three integral points including the origin (0,0,0)(0,0,0) that satisfy the following property:

There exist three different positive integers X,Y,ZX, Y, Z such that for every pair of the three points of the triangle, you can rotate and translate the cuboid of size X×Y×ZX \times Y \times Z in parallel with the grid system so that the pair are diagonally opposite (and so the farthest way) vertices of the cuboid.

For instance, the triangle of the three points (0,0,0),(1,2,3),(2,3,1)(0,0,0), (1,2,3), (-2,3,1) is a grid triangle with the cuboid of size 1×2×31 \times 2 \times 3. More specifically, the two points (1,2,3),(2,3,1)(1,2,3), (-2,3,1) are the diagonally opposite vertices of the cuboid $\{(x,y,z) \mid -2 \le x \le 1, 2 \le y \le 3, 1 \le z \le 3\}$ of size 3×1×23 \times 1 \times 2; the two points (0,0,0),(1,2,3)(0,0,0), (1,2,3) are the diagonally opposite vertices of the cuboid $\{(x,y,z) \mid 0 \le x \le 1, 0 \le y \le 2, 0 \le z \le 3\}$ of size 1×2×31 \times 2 \times 3; and the two points (0,0,0),(2,3,1)(0,0,0), (-2,3,1) are the diagonally opposite vertices of the cuboid $\{(x,y,z) \mid -2 \le x \le 0, 0 \le y \le 3, 0 \le z \le 1\}$ of size 2×3×12 \times 3 \times 1. Further, all three cuboids are parallel with the grid system.

Write a program to output the number of grid triangles within a bounded 3-dimensional grid system. The grid system is bounded by three given positive integers, A,B,CA, B, C, in such a way that all points of grid triangles should be within $\{(x,y,z) \mid -A \le x \le A, -B \le y \le B, -C \le z \le C\}$.

输入格式

Your program is to read from standard input. The input is exactly one line containing three integers, A,B,CA, B, C (1A,B,C10,000,0001 \le A, B, C \le 10,000,000).

输出格式

Your program is to write to standard output. Print exactly one line. The line should contain the number of grid triangles in the 3-dimensional grid system bounded by A,B,CA, B, C.

3 3 3
48
3 3 2
16
3 2 2
0