F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

GCD Tree

Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1003    Accepted Submission(s): 448


Problem Description
Teacher Mai has a graph with $n$ vertices numbered from $1$ to $n$. For every edge($u$,$v$), the weight is gcd($u$,$v$). (gcd($u$,$v$) means the greatest common divisor of number $u$ and $v$).

You need to find a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is maximized. Print the total weight of these edges.
 

Input
There are multiple test cases(about $10^5$).

For each test case, there is only one line contains one number $n(1\leq n\leq 10^5)$.
 

Output
For each test case, print the answer.
 

Sample Input
1 2 3 4 5
 

Sample Output
0 1 2 4 5
 

Author
xudyh
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-19 09:17:10, Gzip enabled