Problem 617B

Правка en3, от ebanner, 2016-11-27 20:12:12

This is a post describing my solution for 617B - Chocolate.

For this problem, the key is recognizing that we can think of breaking the candy bar up into parts as a sequential decision process. Once we know how many ways we can break the candy bar at each stage, we can just apply the rule of product and multiply the number of ways local breaks to the candy bar to produce the total number of ways to break up the candy bar.

The process proceeds as follows. We proceed from left to right. We march along the candy bar until we get between two nuts. Between each pair of nuts, if there are some zeros, we have the option of including the zeros with either the left nut of the right nut. The number of choices we have is the number of zeros, plus one. We continue this for each pair of nuts separated by either none or some zeros.

To help visualize this process, consider the following diagram on the input sequence 10101:

Here is some text afterward.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en8 Английский ebanner 2016-11-27 21:35:36 798 Tiny change: 'e two nuts; hence the' - (published)
en7 Английский ebanner 2016-11-27 21:15:47 1063 Tiny change: ' candy bar and march right\n2. Keep ' -
en6 Английский ebanner 2016-11-27 21:03:32 28
en5 Английский ebanner 2016-11-27 21:02:48 633
en4 Английский ebanner 2016-11-27 20:14:55 159
en3 Английский ebanner 2016-11-27 20:12:12 730
en2 Английский ebanner 2016-11-27 20:06:29 8 Tiny change: 'YD2/pub?w=960&h=720)' -
en1 Английский ebanner 2016-11-26 22:55:10 507 Initial revision (saved to drafts)