//UVA10791MinimumSumLCM
#include<cstdio>
#include<cstring>
#include<cmath>
int n;
long long divide_complete(int& n, int i) {
long long ans = 1;
while(n % i == 0) {
n /= i; ans *= i;
}
return ans;
}
long long solve(int n) {
if(n == 1) return 2;
long long ans = 0, cnt = 0;
int m = floor(sqrt(n + 0.5));
for(int i = 2; i < m; i++) {
if(n % i == 0) {
cnt++;
ans += divide_complete(n, i);//将i除尽
}
}
if(n > 1) { ans += n; cnt++;}//加入n本身
if(cnt <= 1) ans++;//当此数本身是素数时
return ans;
}
int main() {
int kase = 0;
while(scanf("%d", &n) == 1 && n) {
printf("Case %d: ", ++kase);
long long ans = solve(n);
printf("%lld\n", ans);
}
}
/*
12
10
5
0
*/
UVA10791MinimumSumLCM
最新推荐文章于 2018-11-08 08:56:00 发布