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

Problem Description
This problem guarantees that the testdata is generated randomly.
There is a complete graph with vertices, numbered . Between vertices and , there is an undirected edge with weight .
Please find the total weight of the maximum spanning tree of this graph, modulo .
Input Format
This problem contains multiple test cases. The first line contains an integer , representing the number of test cases.
The next lines each contain one integer , representing the number of vertices.
Output Format
Output 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 of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
- For of the testdata, .
A fast Pollard_Rho prime factorization code is provided in the distributed files.
Translated by ChatGPT 5