Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- B is (2^m-1)^n
- Firstly since all the presents need to have at least one "home", let's find and list those first :D
- Consider In the case of n=2 presents and m=3 boxes: (X, Y are presents)
- Also without loss of generality, we mark these as the FIRST OCCURRENCE of the present type
- This is to avoid duplicate counting (X Y+X <-> X X+Y)
- XY _ _
- X Y _
- X _ Y
- Y X _
- _ XY _
- _ X Y
- Y _ X
- _ Y X
- _ _ XY
- Now in each of these case we think about the remaining ways to put the other presents
- An example would definitely help explaining
- Let's take "X Y _"
- Since each present type is independent from each other we can consider them separately and multiply the number of ways together
- Remember, X and Y marks the FIRST occurrence of the present type
- X: In the last two boxes, each of them have two choices: Either you put a X, or you don't. That's 2^2 ways (X _ _, X X _, X _ X, X X X)
- Y: In the last box, it also has two choices: You put a Y, or you don't
- That's 2^1 way
- So "X Y _" (as the "base") will create 2^2 x 2^1 cases as follow
- X Y _ + _ _ _ = X Y __
- X Y _ + _ X _ = X XY __
- X Y _ + _ _ X = X Y X
- X Y _ + _ X X = X XY X
- X Y _ + _ _ Y = X Y Y
- X Y _ + _ X Y = X XY Y
- X Y _ + _ _ XY = X Y XY
- X Y _ + _ X XY = X XY XY
- Now notice that counting similarly,
- BASE 2^X 2^Y
- XY _ _ -> 2^2 x 2^2 ways
- X Y _ -> 2^2 x 2^1 ways
- X _ Y -> 2^2 x 2^0 ways
- Y X _ -> 2^1 x 2^2 ways
- _ XY _ -> 2^1 x 2^1 ways
- _ X Y -> 2^1 x 2^0 ways
- Y _ X -> 2^0 x 2^2 ways
- _ Y X -> 2^0 x 2^1 ways
- _ _ XY -> 2^0 x 2^0 ways
- +)
- ------------------------
- 2^2x(2^2+2^1+2^0)+2^1x(2^2+2^1+2^0)+2^0x(2^2+2^1+2^0)=(2^2+2^1+2^0)^2
- (Make sure you understand the example)
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Finally you can generalise it a bit and think a bit to get
- WAYS = (2^(m-1)+2^(m-2)+...+2^1+2^0)^n=(2^m-1)^n
- Use some binary modulo exponent thing OR use python :)
- Please read omg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement