#P17433. [LBA-OI R5 C] 卿即终解

    ID: 19945 远端评测题 2500ms 512MiB 尝试: 0 已通过: 0 显示难度提高+/省选− 上传者: 标签>数论O2优化莫比乌斯反演Dirichlet 卷积欧拉函数

[LBA-OI R5 C] 卿即终解

Background

::::align{center} 卿即终解,数证初心 ::::

In the final year of high school, Su Wan wrote three summation symbols and a greatest common divisor on scratch paper. Many years later, Lin Mo typed the code again and waited for the screen to output a number—that was an echo after eleven years.

Problem Description

Given nn, compute $\left(\sum\limits_{i=1}^{n}{\sum\limits_{j=1}^{n}{\sum\limits_{k=1}^{n}{i\cdot j\cdot k\cdot\gcd(i,j,k)}}}\right) \bmod 2^{64}$.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT, representing the number of test cases.
The next TT lines each contain one integer nn.

Output Format

Output TT lines. Each line contains one integer, representing the answer.

5
1
2
51
1000
114514
1
35
3188479762
171666321110333776
14226039676014353747

Hint

Constraints for 100%100\% of the data: T≤3000T\le 3000, 1≤n≤3×1071\le n\le 3\times 10^7.

::cute-table{tuack} | Test Point ID | TT | nn | | :---: | :---: | :---: | | 1,21,2 | =5=5 | ≤300\le 300 | | 3,43,4 | ≤3000\le 3000 | ≤100\le 100 | | 5,65,6 | ^ | ≤3000\le 3000 | | 7∼107 \sim 10 | ^ | ≤104\le 10^4 | | 11∼1411 \sim 14 | ^ | ≤106\le 10^6 | | 15∼2015 \sim 20 | ^ | ≤3×107\le 3 \times 10^7 |

Translated by ChatGPT 5