Among permutations of length N, how many satisfy |a_i − i| ≠ K

Правка en5, от elizabeth_zou_fanboi, 2024-11-09 21:00:28

a permutation is valid only if |ai — i| != k for all 1<=i<=n. Count the number of valid permutations.

Constraints: 2 ≤ N ≤ 2000

1 ≤ K ≤ N − 1

EDIT: Thanks for the explanation from methanol.

I implemented that explanation:

cpp code

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en7 Английский elizabeth_zou_fanboi 2024-11-09 21:04:04 2783 Reverted to en5
en6 Английский elizabeth_zou_fanboi 2024-11-09 21:03:06 2783 Reverted to en4
en5 Английский elizabeth_zou_fanboi 2024-11-09 21:00:28 2783
en4 Английский elizabeth_zou_fanboi 2024-11-08 20:51:00 112
en3 Английский elizabeth_zou_fanboi 2024-11-08 20:02:58 4 Tiny change: 'N ≤ 2000\n1 ≤ K ≤ ' -> 'N ≤ 2000\n\n\n1 ≤ K ≤ ' (published)
en2 Английский elizabeth_zou_fanboi 2024-11-08 20:02:30 4 Tiny change: '− i| ≠ K\nConstrai' -> '− i| ≠ K\n\n\nConstrai' (saved to drafts)
en1 Английский elizabeth_zou_fanboi 2024-11-08 20:02:12 174 Initial revision (published)