#include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> #include<math.h> #define ll long long using namespace std; int main(){ int n; int k=0; while(1){ k++; scanf("%d",&n); if (n==0)break; int m=sqrt(n+1); int cnt=0; ll ans=0; for (int i=2;i<=m;i++){ if (n%i==0){ ll num=1; cnt++; while(n%i==0){ num*=i; n/=i; } ans+=num; } if (n==1)break; } if (n!=1 || cnt==0){ ans+=n; cnt++; } if (cnt==1){ ans++; } printf("Case %d: %lld\n",k,ans); } return 0; }
原文地址:https://www.cnblogs.com/bluefly-hrbust/p/9819925.html
时间: 2024-10-16 07:19:39