题目描述

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.

题目分析

题目大意:建图,求图最小边权和:边权为两点序号的Minimum’s Revenge_图论

我们很容易想到:使每条边权最小的时候,应该将所有的点与1点相连,使得所有边权最小化。

因此图的结构被确定了,每条边的边权也唯一固定:Minimum’s Revenge_#include_02。可以推出以下公式:
Minimum’s Revenge_图论_03

AC Code

#include <bits/stdc++.h>
#define
using namespace std;

int main(){
int t = 0, cas = 0; cin >> t;
while(t--){
ll ans = 0, n = 0; cin >> n;
ans = (n + 2) * (n - 1) / 2;
cout << "Case #" << ++cas << ": " << ans << endl;
}
return 0;
}