Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- int main()
- {
- ll n,i,j,k,cas=1;
- while(cin>>n && n)
- {
- cout<<"Case "<<cas++<<": ";
- ll res=0,cnt=0,a,b,c,d;
- a=n;
- if(a==1)
- {
- cout<<2<<endl;
- continue;
- }
- else
- {
- if(a%2==0)
- {
- b=1;
- while(a%2==0)
- {
- b*=2;
- a/=2;
- }
- cnt++;
- res=b;
- }
- for(i=3; i*i<=a; i+=2)
- {
- if(a%i==0)
- {
- b=1;
- while(a%i==0)
- {
- b*=i;
- a/=i;
- }
- cnt++;
- res+=b;
- }
- }
- if(a>1)
- {
- res+=a;
- cnt++;
- }
- if(cnt==1)
- res=n+1;
- cout<<res<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement