#P8670. [蓝桥杯 2018 国 B] 矩阵求和

[蓝桥杯 2018 国 B] 矩阵求和

Problem Description

After passing many written tests and interviews, Xiao Ming successfully joined Macrohard.

Today, Xiao Ming's task is to fill in a table like this:

The table has nn rows and nn columns, and both row and column indices start from 11.

The value of the element in row ii and column jj is the square of gcd(i,j)\gcd(i, j), where gcd\gcd means the greatest common divisor. Below are the first four rows and first four columns of the table:

1  1  1  1
1  4  1  4
1  1  9  1
1  4  1 16

Xiao Ming suddenly had a strange idea. He wants to know the sum of all elements in this table.
Since the table is too large, he hopes to use the power of a computer.

Input Format

One line with one positive integer nn, as described in the problem.

Output Format

One line with one number, the sum of all elements. Since the answer is large, output the result modulo 10000000071000000007 (i.e. 109+710^9+7).

4
48

Hint

For 30%30\% of the testdata, n1000n \le 1000.

There is 10%10\% of the testdata where n=105n = 10^5.

For 60%60\% of the testdata, n106n \le 10^6.

For 100%100\% of the testdata, n107n \le 10^7.

Translated by ChatGPT 5