Victor's Various Adventures - Victor Counts Marbles
View as PDFThis is problem 2 of the Victor's Various Adventures problem set.
Victor is doing a question on his Data Management homework, but he isn't sure if he has the right answer. The question is as follows:
Given a row of
slots, where, in each slot a
BlackorWhitemarble can be placed. Note that marbles of the same color are identical to each other.Count the total number of placements where no more than
of the same-colored marbles next to each other.
Will you help him find the right answer?
Input Specification
The first and only line of input contains the space-separated integers  
 and 
 
.
Output Specification
Output the correct answer on one line.
Sample Input 1
4 2Sample Output 1
10Explanation for Sample Output 1
The total number of possible arrangements (without the restriction) are: (B is for Black, and W is for White)
BBBB
BBBW
BBWB
BBWW
BWBB
BWBW
BWWB
BWWW
WBBB
WBBW
WBWB
WBWW
WWBB
WWBW
WWWB
WWWWOnce we remove the ones that do not meet the condition, the remaining are:
BBWB
BBWW
BWBB
BWBW
BWWB
WBBW
WBWB
WBWW
WWBB
WWBW
Comments