#P9488. ZHY 的生成树

ZHY 的生成树

Problem Description

ZHY has a complete graph with nn vertices. The distance (edge weight) between vertex uu and vertex vv is gcd(u,v)\gcd(u,v). Find the sum of edge weights of the maximum spanning tree of this complete graph.

Input Format

A positive integer nn.

Output Format

An integer, representing the sum of edge weights of the maximum spanning tree.

4
4
30
183
100
1916

Hint

This problem uses bundled testdata.

Subtask\text{Subtask} 00\kern{3pt}(10pts): n5n\le 5.

Subtask\text{Subtask} 11\kern{3pt}(20pts): n1000n\le 1000.

Subtask\text{Subtask} 22\kern{3pt}(30pts): n106n\le 10^{6}.

Subtask\text{Subtask} 33\kern{3pt}(40pts): n107n\le 10^{7}.

For all testdata, 1n1071\le n \le 10^{7}.

Translated by ChatGPT 5