F(x,m,c,i){for(i=x;i;i/=10)c+=i%10;for(i=2;i<=x;i++)m=fmax(m,x%i?0:(F(x/i,1,0)+c));return m;}main(N){for(;~scanf("%d",&N);printf("%d\n",F(N,1,0)));}
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page