#P15367. 秋季限定生成树问题

    ID: 17425 远端评测题 750ms 512MiB 尝试: 0 已通过: 0 显示难度NOI/NOI+/CTS 上传者: 标签>贪心数论深度优先搜索 DFS素数判断,质数,筛法最大公约数 gcd容斥原理Ad-hoc筛法

秋季限定生成树问题

Background

Problem Description

This problem guarantees that the testdata is generated randomly.

There is a complete graph with nn vertices, numbered 1,2,…,n1,2,\ldots,n. Between vertices ii and jj, there is an undirected edge with weight lcm(i,j)+gcd(i,j)\mathrm{lcm}(i,j)+\mathrm{gcd}(i,j).

Please find the total weight of the maximum spanning tree of this graph, modulo 2322^{32}.

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, representing the number of vertices.

Output Format

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

9
10
1000
100000
10000000
1000000000
100000000000
10000000000000
1000000000000000
100000000000000000
422
499008694
4172096327
3128649679
2692599804
194024000
2969759816
505684415
3052141644

Hint

There are subtasks.

Constraints

  • For 5%5\% of the testdata, T=1,n≤2000T=1,n\leq 2000.
  • For 15%15\% of the testdata, T=1,n≤106T=1,n\leq 10^6.
  • For 30%30\% of the testdata, T=1,n≤108T=1,n\leq 10^8.
  • For 50%50\% of the testdata, T=1,n≤1010T=1,n\leq 10^{10}.
  • For 75%75\% of the testdata, T=1,n≤1015T=1,n\leq 10^{15}.
  • For 100%100\% of the testdata, T≤10,n≤1018T\leq 10,n\leq 10^{18}.

A fast Pollard_Rho prime factorization code is provided in the distributed files.

Translated by ChatGPT 5