Code:
#include<cstdio> #include<algorithm> #include<cmath> #include<string> using namespace std; typedef long long ll; void setIO(string a){freopen((a+".in").c_str(),"r",stdin);} int main(){ //setIO("input"); ll n,ans; while(scanf("%lld",&n)!=EOF){ ans=n; for(ll i=2;i<=(ll)sqrt(n*1.0);++i){ int a=i; if(n%i==0) { int p=0; while(n%i==0){ ++p; n/=i; } ans+=ans*p*(a-1)/a; } } if(n!=1) ans+=ans*(n-1)/n; printf("%lld ",ans); } return 0; }