﻿HDU 5922 Minimum’s Revenge-Ocrosoft

# Minimum’s Revenge

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?

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.



Solution

#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define ms(a) memset(a,0,sizeof(a))
typedef long long LL;
const LL LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const int MAXN = 100000 + 10;
const int MOD = 100000;
const double eps = 1e-6;
int gcd(int a, int b)
{
if (!b)return a;
return gcd(b, a%b);
}
using namespace std;
//or2..or2..or2..or2..or2..//
int main()
{
LL n;
while (cin >> n)
{
for (LL i = 1; i <= n; i++)
{
LL t; cin >> t;
printf("Case #%I64d: %I64d\n", i, (2 + t)*(t - 1) / 2);
}
}
return 0;
}