Minimum’s Revenge

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 1409    Accepted Submission(s): 749


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 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

Hint

In 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

思路:水题,注意变量类型设为long long

#include <iostream>
#include<stdio.h>
using namespace std; int main()
{
int t;
scanf("%d",&t);
long long n;
int path=1;
while(t--)
{
scanf("%lld",&n);
long long sum=0;
sum=((2+n)*(n-1))/2;
printf("Case #%d: %lld\n",path++,sum);
}
return 0;
}

hdu5922Minimum’s Revenge的更多相关文章

  1. HDU 3341 Lost's revenge(AC自动机+DP)

    Lost's revenge Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)T ...

  2. HDU 5019 Revenge of GCD(数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 Problem Description In mathematics, the greatest ...

  3. L - Abbott's Revenge(比较复杂的bfs)

    Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UV ...

  4. hdu 4099 Revenge of Fibonacci 大数+压位+trie

    最近手感有点差,所以做点水题来锻炼一下信心. 下周的南京区域赛估计就是我的退役赛了,bless all. Revenge of Fibonacci Time Limit: 10000/5000 MS ...

  5. HDU5088——Revenge of Nim II(高斯消元&矩阵的秩)(BestCoder Round #16)

    Revenge of Nim II Problem DescriptionNim is a mathematical game of strategy in which two players tak ...

  6. HDU5087——Revenge of LIS II(BestCoder Round #16)

    Revenge of LIS II Problem DescriptionIn computer science, the longest increasing subsequence problem ...

  7. HDU5086——Revenge of Segment Tree(BestCoder Round #16)

    Revenge of Segment Tree Problem DescriptionIn computer science, a segment tree is a tree data struct ...

  8. UVA 816 - Abbott&#39;s Revenge(BFS)

    UVA 816 - Abbott's Revenge option=com_onlinejudge&Itemid=8&page=show_problem&category=59 ...

  9. hdu 4099 Revenge of Fibonacci Trie树与模拟数位加法

    Revenge of Fibonacci 题意:给定fibonacci数列的前100000项的前n位(n<=40);问你这是fibonacci数列第几项的前缀?如若不在前100000项范围内,输 ...

随机推荐

  1. 网络编程基础:粘包现象、基于UDP协议的套接字

    粘包现象: 如上篇博客中最后的示例,客户端有个 phone.recv(2014) , 当服务端发送给客户端的数据大于1024个字节时, 多于1024的数据就会残留在管道中,下次客户端再给服务端发命令时 ...

  2. hdu - 2066 一个人的旅行(基础最短路)

    http://acm.hdu.edu.cn/showproblem.php?pid=2066 把与草儿相连的城市最短距离置为0,然后进行dijkstra,在t个城市里找出距离最近的一个即可. #inc ...

  3. POJ 2240_Arbitrage

    题意: 给定一系列货币汇率,求能否从一种货币,经过一系列转换,最终转化回更高价值的该种货币. 分析: 即为求最长路并判断是否存在"正"权值回路,这里用的bellmanford算法. ...

  4. mysql 安装与卸载

    mysql用了也好几年了,但每次安装完或者卸载完就忘记了安装步骤以及卸载步骤,因此将关键的步骤记录下来,供以后参考. 1.mysql安装 ①安装类型有typical,complete,custom,一 ...

  5. JSP中访问数据库

    在JSP中访问数据库使用的是JSTL标签,本文不按照http://wiki.jikexueyuan.com/project/jsp/database-access.html此方法进行实践,而是采用之前 ...

  6. 【.Net 学习系列】-- .Net 指定时间段内定时执行的Windows服务(System.Threading.Thread)

    创建一个Windows服务项目:解决方案(右击)——> 添加 ——> 新建项目——>项目类型选择Windows——>模板选择Windows服务 ,如图: 编写Windows服务 ...

  7. 【LeetCode-面试算法经典-Java实现】【067-Add Binary(二进制加法)】

    [067-Add Binary(二进制加法)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given two binary strings, return thei ...

  8. Android 实现形态各异的双向側滑菜单 自己定义控件来袭

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/39670935.本文出自:[张鸿洋的博客] 1.概述 关于自己定义控件側滑已经写了 ...

  9. vuex资料

    vuex最简单.最详细的入门文档 链接:https://segmentfault.com/a/1190000009404727 https://www.jb51.net/article/138239. ...

  10. storm与hadoop的对照

       hadoop 是实现了 mapreduce 的思想,将数据切片计算来处理大量的离线数据. hadoop处理的数据必须是已经存放在 hdfs 上或者类似 hbase 的数据库中.所以 hadoop ...