luogu#P3166. [CQOI2014] 数三角形

    ID: 2235 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2014重庆各省省选最大公约数 gcd排列组合

[CQOI2014] 数三角形

Problem Description

Given an N×MN \times M grid, compute how many triangles have all three vertices at grid points. Note that the three points of a triangle must not be collinear.

Input Format

The input consists of one line containing two space-separated positive integers MM and NN.

Output Format

Output a single positive integer, which is the number of such triangles.

2 2
76

Hint

Constraints

For all test points, 1N,M10001 \le N, M \le 1000.

Translated by ChatGPT 5