HDU5922-Minimum’s Revenge
来源:互联网 发布:手机淘宝改支付宝绑定 编辑:程序博客网 时间:2024/06/08 06:20
Minimum’s Revenge
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1307 Accepted Submission(s): 681
Problem 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 multipleof their indexes.
Mr. Frog is wondering about the total weight of the minimum spanning tree. Can you help him?
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.
For each test case, the first line contains only one integer n (
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
223
Sample Output
Case #1: 2Case #2: 5HintIn the second sample, the graph contains 3 edges which are (1, 2, 2), (1, 3, 3) and (2, 3, 6). Thus the answer is 5.
Source
2016CCPC东北地区大学生程序设计竞赛 - 重现赛
Recommend
wange2014
题意:给你n个点,这些点之间添加n-1条边,形成一个不带环的树,边的权值为边连接的两点的乘积
解题思路:将所有不是1的点和1号点相连
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <string>#include <math.h>#include <time.h>#include <algorithm>#include <vector>#include <stack>#include <queue>#include <map>#include <set>using namespace std;const int INF = 0x3f3f3f3f3f;#define LL long longint main(){int t,cas=0;scanf("%d", &t);while (t--){LL n;scanf("%lld", &n);printf("Case #%d: %lld\n",++cas, (2 + n)*(n - 1) / 2);}return 0;}
阅读全文
0 0
- HDU5922-Minimum’s Revenge
- Minimum’s Revenge HDU5922 (水t)
- 【HDU5922 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 A】【水题】Minimum’s Revenge
- hdu5922 2016CCPC东北地区大学生程序设计竞赛 A题 Minimum’s Revenge(思维,水题)
- Minimum’s Revenge
- Minimum’s Revenge
- hdu 5922/Minimum’s Revenge
- hdu 5922 Minimum’s Revenge
- 2016CCPC东北-A.Minimum’s Revenge
- hdu 5922 Minimum’s Revenge【贪心】水题
- hdu 5922 Minimum’s Revenge 贪心
- 2016CCPC东北地区大学生程序设计竞赛-Minimum’s Revenge
- HDU 5922 Minimum’s Revenge 【最小生成树】
- Minimum’s Revenge(弱校联盟十一专场)
- hdu5922
- hdu5922
- HDU Minimum’s Revenge 2016CCPC东北地区大学生程序设计竞赛 - 重现赛
- [2016CCPC东北地区大学生程序设计竞赛] Minimum’s Revenge 贪心+水题
- Java数据类型
- QT下将数组里的数据画成曲线
- C++ limits头文件的用法(numeric_limits)
- dibian9安装java8
- PHP header 的几种用法
- HDU5922-Minimum’s Revenge
- Android 图片高斯模糊解决方案
- OpenWrt 编译及batman-adv组件选择(for Netgear WNDR3800)
- 多线程
- 纯真IP地址库合并
- HBuilder mui入门教程——(1)简介
- HDU-1863- 畅通工程(最小生成树,prim)
- 56 WebGL处理响应上下文丢失
- 堆模板