2016CCPC东北地区大学生程序设计竞赛 - 重现赛 A - Minimum’s Revenge HDU 5922

这是一个关于程序设计竞赛的问题,描述了一个包含n个顶点的图,每对不同顶点间边的权重是它们编号的最小公倍数。任务是计算最小生成树的总权重。样例输入和输出展示了如何处理小规模测试用例。解决策略是将每个顶点与编号为1的顶点连接,得到的权值总和即为答案,即(n+2)*(n-1)/2。
摘要由CSDN通过智能技术生成

Description
There is a graph of n vertices which are indexed from 1 to n. For any pair of different vertices, the weight of the edge between them is the least common multiple of their indexes.

Mr. Frog is wondering about the total weight of the minimum spanning tree. Can you help him?

Input
The first line contains only one integer T (T≤100), which indicates the number of test cases.

For each test case, the first line contains only one integer n (2≤n≤109), indicating the number of vertices.

Output
For each test case, output one line “Case #x:y”,where x is the case number (starting from 1) and y is the total weight of the minimum spanning tree.

Sample Input

2
2
3

Sample Output

Case #1: 2
Case #2: 5
题意:给你一个完全图,然后每条边的权值是两端点标号的LCM
然后需要你构造一个最小生成树,使得权和最小
那么树保证每个点都是在树上的把,所以每个点都需要联通,
很容易想到和1连接的时候就是最小的,所以只需要每个点都和

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值