Advertisement
Guest User

THIS IS FORMATTED

a guest
Oct 17th, 2019
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. B is (2^m-1)^n
  2.  
  3. Firstly since all the presents need to have at least one "home", let's find and list those first :D
  4.  
  5. Consider In the case of n=2 presents and m=3 boxes: (X, Y are presents)
  6. Also without loss of generality, we mark these as the FIRST OCCURRENCE of the present type
  7. This is to avoid duplicate counting (X Y+X <-> X X+Y)
  8. XY _ _
  9. X Y _
  10. X _ Y
  11. Y X _
  12. _ XY _
  13. _ X Y
  14. Y _ X
  15. _ Y X
  16. _ _ XY
  17.  
  18. Now in each of these case we think about the remaining ways to put the other presents
  19. An example would definitely help explaining
  20.  
  21. Let's take "X Y _"
  22. Since each present type is independent from each other we can consider them separately and multiply the number of ways together
  23. Remember, X and Y marks the FIRST occurrence of the present type
  24. 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)
  25. Y: In the last box, it also has two choices: You put a Y, or you don't
  26. That's 2^1 way
  27. So "X Y _" (as the "base") will create 2^2 x 2^1 cases as follow
  28. X Y _ + _ _ _ = X Y __
  29. X Y _ + _ X _ = X XY __
  30. X Y _ + _ _ X = X Y X
  31. X Y _ + _ X X = X XY X
  32. X Y _ + _ _ Y = X Y Y
  33. X Y _ + _ X Y = X XY Y
  34. X Y _ + _ _ XY = X Y XY
  35. X Y _ + _ X XY = X XY XY
  36.  
  37. Now notice that counting similarly,
  38. BASE 2^X 2^Y
  39. XY _ _ -> 2^2 x 2^2 ways
  40. X Y _ -> 2^2 x 2^1 ways
  41. X _ Y -> 2^2 x 2^0 ways
  42. Y X _ -> 2^1 x 2^2 ways
  43. _ XY _ -> 2^1 x 2^1 ways
  44. _ X Y -> 2^1 x 2^0 ways
  45. Y _ X -> 2^0 x 2^2 ways
  46. _ Y X -> 2^0 x 2^1 ways
  47. _ _ XY -> 2^0 x 2^0 ways
  48. +)
  49. ------------------------
  50. 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
  51. (Make sure you understand the example)
  52. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53. Finally you can generalise it a bit and think a bit to get
  54. WAYS = (2^(m-1)+2^(m-2)+...+2^1+2^0)^n=(2^m-1)^n
  55. Use some binary modulo exponent thing OR use python :)
  56.  
  57. Please read omg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement