atcoder#TOKIOMARINE2020F. Triangles

Triangles

Score : 10001000 points

Problem Statement

In a two-dimensional plane, we have a rectangle RR whose vertices are (0,0)(0,0), (W,0)(W,0), (0,H)(0,H), and (W,H)(W,H), where WW and HH are positive integers. Here, find the number of triangles Δ\Delta in the plane that satisfy all of the following conditions:

  • Each vertex of Δ\Delta is a grid point, that is, has integer xx- and yy-coordinates.
  • Δ\Delta and RR shares no vertex.
  • Each vertex of Δ\Delta lies on the perimeter of RR, and all the vertices belong to different sides of RR.
  • Δ\Delta contains at most KK grid points strictly within itself (excluding its perimeter and vertices).

Constraints

  • 1W1051 \leq W \leq 10^5
  • 1H1051 \leq H \leq 10^5
  • 0K1050 \leq K \leq 10^5

Input

Input is given from Standard Input in the following format:

WW HH KK

Output

Print the answer.

2 3 1
12

For example, the triangle with the vertices (1,0)(1,0), (0,2)(0,2), and (2,2)(2,2) contains just one grid point within itself and thus satisfies the condition.

5 4 5
132
100 100 1000
461316