Code Festival C Div and Add by hirokazu1020

def f(n)([1]+(2..n).map{|i|n%i==0?f(n/i)+n/100+n/10%10+n%10:0}).max end
while n=gets
p f(n.to_i) end

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page