302334: CF449E. Jzzhu and Squares

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Jzzhu and Squares

题意翻译

Jzzhu 获得了一个 n×m 的方格棋盘。 在棋盘中,存在许多格点正方形,也就是四个顶点均在格点的正方形。 对于每个格点正方形 R, Jzzhu 定义了 f(R) 表示被其完全包含的方格数。 也就是数对 (x,y) 的对数,其中 0≤x<n,0≤y<m,且 (x,y),(x,y+1),(x+1,y),(x+1.y+1) 均在 R 内部或边界。 Jzzhu现在想知道对于所有不同的格点正方形,他们 f 函数值之和为多少,你只需要告诉他在模 1e9+7 意义下的值即可。

题目描述

Jzzhu has two integers, $ n $ and $ m $ . He calls an integer point $ (x,y) $ of a plane special if $ 0<=x<=n $ and $ 0<=y<=m $ . Jzzhu defines a unit square as a square with corners at points $ (x,y) $ , $ (x+1,y) $ , $ (x+1,y+1) $ , $ (x,y+1) $ , where $ x $ and $ y $ are some integers. Let's look at all the squares (their sides not necessarily parallel to the coordinate axes) with corners at the special points. For each such square Jzzhu paints a dot in every unit square that is fully inside it. After that some unit squares can contain several dots. Now Jzzhu wonders, how many dots he has painted on the plane. Find this number modulo $ 1000000007 $ $ (10^{9}+7) $ .

输入输出格式

输入格式


The first line contains a single integer $ t $ $ (1<=t<=10^{5}) $ — the number of tests. Each of the next $ t $ lines contains the description of the test: two integers $ n $ and $ m $ $ (1<=n,m<=10^{6}) $ — the value of variables for the current test.

输出格式


For each test output the total number of dots modulo $ 1000000007 $ $ (10^{9}+7) $ .

输入输出样例

输入样例 #1

4
1 3
2 2
2 5
3 4

输出样例 #1

3
8
26
58

Input

题意翻译

Jzzhu 获得了一个 n×m 的方格棋盘。 在棋盘中,存在许多格点正方形,也就是四个顶点均在格点的正方形。 对于每个格点正方形 R, Jzzhu 定义了 f(R) 表示被其完全包含的方格数。 也就是数对 (x,y) 的对数,其中 0≤x<n,0≤y<m,且 (x,y),(x,y+1),(x+1,y),(x+1.y+1) 均在 R 内部或边界。 Jzzhu现在想知道对于所有不同的格点正方形,他们 f 函数值之和为多少,你只需要告诉他在模 1e9+7 意义下的值即可。

加入题单

算法标签: