#nt1004. LCMSUM1
LCMSUM1
LCMSUM 1
Problem Description
queries. Each query gives an ; output , where denotes .
Input Format
The first line contains one integer . The following lines each contain one integer representing the number .
Output Format
One integer per line: the answer.
Sample Input
3
10
123
1234567
Sample Output
320
706512
933390306503591194
Constraints
For all data, it is guaranteed that , .
Hint
- Rewrite $\sum_{i=1}^n \operatorname{lcm}(i,n) = n\sum_{i=1}^n \frac{i}{\gcd(i,n)}$ and group by ; this reduces to a divisor sum involving Euler's totient function. Precompute with a linear sieve, then answer each query in (or faster with prefix sums), taking the modulus with 64-bit unsigned arithmetic.