elizabeth_zou_fanboi's blog

By elizabeth_zou_fanboi, history, 39 hours ago, In English

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

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it