#P1945. 无边的网格

无边的网格

Description

In a table with RR rows and CC 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 RR and CC (R,C10R,C \le 10), 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 RR and CC 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 22 positive integers RR and CC separated by a single space.

Output Format

One line containing 22 integers ans1\mathit{ans}_1 and ans2\mathit{ans}_2 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 30%30\% of the testdata, R,C50R,C \le 50.
  • For 50%50\% of the testdata, R,C103R,C \le 10^3.
  • For 70%70\% of the testdata, R,C105R,C \le 10^5, ans1,ans2<263\mathit{ans}_1,\mathit{ans}_2<2^{63}.
  • For 90%90\% of the testdata, R,C10100R,C \le 10^{100}.
  • For 100%100\% of the testdata, R,C101000R,C \le 10^{1000}.

Translated by ChatGPT 5