Distributing the balls by Rivu Das

import sys
f=lambda n,k:(n and k and n>=k and k*(f(n-1,k-1)+f(n-1,k)))or(n+k==0 and 1)or 0
for l in sys.stdin:print f(*(map(int,l.split())))

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

download

return top