您的位置:首页 > 其它

【HDU5922 2016CCPC东北地区大学生程序设计竞赛 - 重现赛 A】【水题】Minimum’s Revenge

2016-10-08 16:32 656 查看

Minimum’s Revenge

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

Total Submission(s): 129    Accepted Submission(s): 111


[align=left]Problem Description[/align]
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?

 

[align=left]Input[/align]
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.

 

[align=left]Output[/align]
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.

 

[align=left]Sample Input[/align]

2
2
3

 

[align=left]Sample Output[/align]

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.

 

[align=left]Source[/align]
2016CCPC东北地区大学生程序设计竞赛
- 重现赛
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x,y) memset(x,y,sizeof(x))
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;
template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }
int casenum, casei;
LL n;
int main()
{
scanf("%d", &casenum);
for (casei = 1; casei <= casenum; ++casei)
{
scanf("%lld", &n);
LL ans = (1 + n)*n / 2 - 1;
printf("Case #%d: %lld\n", casei, ans);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐