P28654 [洛谷] Surface
提高+
题目描述

Problem Background

xht enjoys studying mathematical functions, especially the inverse proportional function.

Problem Description

We know that the graph of the inverse proportional function \(xy = a\) is a hyperbola.

xht wonders: what would it look like in three dimensions?

Define the surface \(C(k)\) as the surface determined by the equation \(xyz = k\).

Next, define the aesthetic value \(P(k)\) of the surface \(C(k)\) as the sum of the squares of the Manhattan distances from all integer points (where \(x\), \(y\), and \(z\) are integers) to the origin.

(The Manhattan distance from point \((x, y, z)\) to the origin is \(|x| + |y| + |z|\).)

Now, xht arranges a series of surfaces \(\{C(a), C(a+1), \ldots, C(b)\}\) in a row, and you are to find the sum of their aesthetic values modulo 10007.

Input Format

A single line containing two positive integers \(a\) and \(b\).

Output Format

A single number.

Sample Input and Output

Sample Input #1

3 3

Sample Output #1

300

Sample Input #2

64 19260817

Sample Output #2

9932

Notes

Explanation of Sample 1:

On the surface \(xyz = 3\), there are 12 integer points: \((1, 1, 3)\), \((1, 3, 1)\), \((3, 1, 1)\), \((-1, -1, 3)\), \((-1, -3, 1)\), \((-3, -1, 1)\), \((1, -1, -3)\), \((1, -3, -1)\), \((3, -1, -1)\), \((-1, 1, -3)\), \((-1, 3, -1)\), \((-3, 1, -1)\). The sum of the squares of their Manhattan distances to the origin is \(5^2 \times 12 = 300\).

For 20% of the data, \(a = b \leq 100\).

For another 40% of the data, \(a, b \leq 3 \times 10^5\).

For 100% of the data, \(1 \leq a, b \leq 3 \times 10^8\).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3
样例输出
300