CF449E.Jzzhu and Squares
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 (109 + 7).
Jzzhu 有两个整数 n 和 m。他称平面上的一个整点 (x,y) 为特殊点,当且仅当 0≤x≤n 且 0≤y≤m。Jzzhu 将单位正方形定义为以点 (x,y)、(x+1,y)、(x+1,y+1)、(x,y+1) 为顶点的正方形,其中 x 和 y 均为整数。
考虑所有以特殊点为顶点的正方形(其边不一定与坐标轴平行)。对每一个这样的正方形,Jzzhu 在完全位于该正方形内部的每一个单位正方形中画一个点。此后,某些单位正方形中可能包含多个点。现在 Jzzhu 想知道:他在整个平面上一共画了多少个点?请输出该数目对 1000000007(即 109+7)取模的结果。
输入格式
The first line contains a single integer t (1 ≤ t ≤ 105) — the number of tests.
Each of the next t lines contains the description of the test: two integers n and m (1 ≤ n, m ≤ 106) — the value of variables for the current test.
第一行包含一个整数 t(1≤t≤105)—— 测试用例的数量。
接下来的 t 行,每行描述一个测试用例:两个整数 n 和 m(1≤n,m≤106)—— 当前测试用例中变量的值。
输出格式
For each test output the total number of dots modulo 1000000007 (109 + 7).
对每个测试用例,输出点的总数对 1000000007(109+7)取模的结果。
输入输出样例
输入#1
4 1 3 2 2 2 5 3 4
输出#1
3 8 26 58
输入解题思路,AI测评打分。不知道怎么写?