因为边权是两个数之间的lcm,而对于所有的数,1和任意数的lcm都是最小的,故只需要求2 + 3 + 4 + 5 + ...... + n即可
代码如下:
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cctype>
#include <string>
#include <queue>
#define debug printf("debug\n")
#define mst(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=1e5+5;
int main()
{
ll t;
cin>>t;
ll n;
ll kase=0;
while(t--)
{
cin>>n;
ll ans=((n+2)*(n-1))/2;
printf("Case #%lld: %lld\n",++kase,ans);
}
return 0;
}