#P10636. BZOJ3518 点组计数

BZOJ3518 点组计数

Problem Description

There is an n×mn \times m lattice of points on the plane, as shown in the following figure for a 3×43 \times 4 lattice:

Now ask: how many unordered triples of points (a,b,c)(a,b,c) satisfy that points a,b,ca,b,c are collinear. The order does not matter; for example, (a,b,c)(a,b,c) and (b,c,a)(b,c,a) are considered the same triple. Output the answer modulo 109+710^9+7.

Constraints

Compute the answer modulo 109+710^9+7.

Input Format

One line with two positive integers n,mn,m.

Output Format

One line with one integer, the result after taking modulo 109+710^9+7.

3 4
20

Hint

The testdata guarantees that 1n,m5×1041\leq n,m\leq 5\times 10^4.

Translated by ChatGPT 5