Mr.Awesome's blog

By Mr.Awesome, history, 8 years ago, In English

I was checking some solution of this problem, and I didn't understand 2 things, let's look at this solution , first why we loop over k j(0..k), and second why k replaced by j and k-j in each call?

Tags dp
  • Vote: I like it
  • +1
  • Vote: I do not like it

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

when you're trying to cut the bar of chocolate in every horizental and vertical way, you also need to try to take every possible number of chocolate squares from the new chocolate bar.so you're looping over k and trying to take every possible number of chocolate squares every time you cut the chocolate bar