Finding number of arrays such that first and last elements are same with unequal adjacent elements.

Правка en1, от hack-it, 2020-12-19 14:44:15

The first and last elements of the array are the same. The size of the array is n and the array element can have values in [1, m]. How to find the number of such arrays with the condition that adjacent elements are unequal?

example: n=3, m=3; ans=6 n=3, m=4; ans=12 n=4, m=4; ans=24

Feels like it can be solved using the inclusion-exclusion principle, But I'm not able to formulate it. Can anyone help?

Теги #combinatorics, #permutation, #combinations, #discrete math, #inclusion-exclusion

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский hack-it 2020-12-19 14:44:15 509 Initial revision (published)