Under construction

Still being built. Things may change

Polygons

Time limit10sMemory limit1024 MB

Summary
Count convex polygons on an X by Y lattice grid whose sides have no interior lattice points and integer length at most K, modulo 2^32.
Level

Hard9 of 10

Topics
Number theory, Geometry, Combinatorics, Dynamic programming
Solved
No attempts yet

Problem

We are already tired and have no idea for an interesting story problem. The task is simply to count convex polygons with short integer sides and no extra lattice points. Let the vertices be (xi,yi)(x_i, y_i). The following conditions must hold.

  • 1≤xi≤X1 \le x_i \le X, 1≤yi≤Y1 \le y_i \le Y
  • The vertices are lattice points, so xix_i and yiy_i are integers.
  • No lattice point lies on any side except the vertices themselves.
  • The length of each side is an integer not greater than KK.
  • The polygon is convex, simple, and non-degenerate. Every interior angle is less than 180 degrees, no edges cross, and there are at least three vertices. No three vertices are collinear.

The figure below shows invalid polygons. The first and second have a lattice point on one of their sides. The second and third are not convex. The first and third have sides whose lengths are not integers.

Input

The first and only line contains three integers XX, YY, and KK (1≤X,Y≤1091 \le X, Y \le 10^9, 1≤K≤2501 \le K \le 250). They are the bounds on the coordinates and on the side length.

Each test group belongs to at least one of the following subtasks. For example, there is no test with X=Y=K=233X = Y = K = 233, because it fits no subtask.

  • K≤15K \le 15
  • X,Y≤150X, Y \le 150
  • 2000≤X,Y≤24002000 \le X, Y \le 2400, K≤100K \le 100
  • XX and YY are divisible by 10610^6

Output

Print the number of valid polygons modulo 2322^{32}. Two polygons are different if some point is a vertex of one of them but not the other.

Hint

In the sample, X=6X = 6, Y=5Y = 5, K=5K = 5. One of the 42 valid polygons has vertices (2,1),(2,2),(6,5),(3,1)(2, 1), (2, 2), (6, 5), (3, 1), shown in the figure below.

Examples1

  1. Example 1

    Input
    6 5 5
    
    Expected output
    42