#P1945. 无边的网格
无边的网格
Description
In a table with rows and columns, each cell is a square. Such a table is called a "grid", and the four vertices of each cell are called "lattice points". A square whose four vertices all lie on lattice points is called a "lattice square"; similarly, an equilateral triangle whose three vertices all lie on lattice points is called a "lattice equilateral triangle".
For given positive integers and (), please compute the numbers of lattice squares and lattice equilateral triangles in the grid.
GZH has seen this kind of problem many times on math exams. After some daydreaming, he thinks it is akin to classic problem types such as grid problems, counting problems, and symmetry problems, and can be solved quickly. However, he also finds that once and no longer satisfy the condition in the statement and become very large, the counting becomes tedious.
Of course, you will be delighted by this, because programming can help here again.
Can you write a program to help GZH complete this tedious counting on this boundless grid?
Input Format
One line containing positive integers and separated by a single space.
Output Format
One line containing integers and separated by a single space, representing in order the numbers of lattice squares and lattice equilateral triangles in the grid.
2 3
10 0
Hint
Sample Explanation

The input asks for the numbers of lattice squares and lattice equilateral triangles in the figure.
- The number of lattice squares is counted as follows:

There are ten in total. - It is not hard to see that no lattice equilateral triangle can be found in the given grid.
Constraints and Notes
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , .
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号