fork(5) download
  1. S = {0,1,2,3,4,5}
  2. i = 7
  3. k = 17
  4.  
  5. # this is in the step i=0, described in the base case
  6. # where f(0,0)=1 and f(0,k)=0 for non-zero k
  7. intermediates = [1] + [0]*k
  8.  
  9. for _ in range(i):
  10. temp = []
  11. for x in range(k+1):
  12. temp.append(sum(intermediates[x-s] if 0 <= x-s <= k else 0 for s in S))
  13. intermediates = [x for x in temp] # deep copy
  14.  
  15. print(intermediates[k])
Success #stdin #stdout 0.01s 27704KB
stdin
Standard input is empty
stdout
24017