题目链接:Minimum Sum LCM UVA - 10791
题目:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<iomanip>
#define ll long long
using namespace std;
const int maxn = 1e4+7;
ll n;
int main()
{
int cas = 0;
while(1) {
scanf("%lld", &n);
if(n == 0) break;
long long sum = 0, tmp = sqrt(n), cnt = 0;
for (int i = 2; i <= tmp; i++) {
if (n % i == 0) {
int c = 1;
cnt++;
while (n % i == 0) {
c *= i;
n /= i;
}
sum += c;
}
}
if (n > 1 || cnt == 0) {
sum += n;
cnt++;
}
if (cnt == 1) sum++;
printf("Case %d: %lld\n", ++cas, sum);
}
return 0;
}