#P16614. [GKS 2017 #A] Square Counting

    ID: 16569 Type: RemoteJudge 1000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>数学2017Google Kick Start

[GKS 2017 #A] Square Counting

题目描述

Mr. Panda has recently fallen in love with a new game called Square Off, in which players compete to find as many different squares as possible on an evenly spaced rectangular grid of dots. To find a square, a player must identify four dots that form the vertices of a square. Each side of the square must have the same length, of course, but it does not matter what that length is, and the square does not necessarily need to be aligned with the axes of the grid. The player earns one point for every different square found in this way. Two squares are different if and only if their sets of four dots are different.

Mr. Panda has just been given a grid with RR rows and CC columns of dots. How many different squares can he find in this grid? Since the number might be very large, please output the answer modulo 109+710^9 + 7 (10000000071000000007).

输入格式

The first line of the input gives the number of test cases, TT. TT lines follow. Each line has two integers RR and CC: the number of dots in each row and column of the grid, respectively.

输出格式

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the number of different squares can be found in the grid.

4
2 4
3 4
4 4
1000 500
Case #1: 3
Case #2: 10
Case #3: 20
Case #4: 624937395

提示

The pictures below illustrate the grids from the three sample cases and a valid square in the third sample case.

:::align{center}

:::

Limits

1T1001 \le T \le 100.

Small dataset (Test set 1 - Visible)

2R10002 \le R \le 1000.

2C10002 \le C \le 1000.

Large dataset (Test set 2 - Hidden)

2R1092 \le R \le 10^9.

2C1092 \le C \le 10^9.