Mathematics (JEE)HardCodeforces Div2 D
How many permutations of {1, 2, ..., 8} have no two adjacent entries whose values differ by exactly 1 (that is, |p(i) - p(i+1)| != 1 for every i from 1 to 7)?
- A. 7208
- B. 5242
- C. 6748
- D. 40320
Correct answer: B. 5242
Checking all 8! = 40320 permutations against the rule |p(i) - p(i+1)| != 1 for all 7 adjacent pairs leaves 5242 permutations.
Practise more Permutations, Combinations and Probability questionsPermutations, Combinations and Probability: notes and key points
More Permutations, Combinations and Probability questions
- How many functions from a 6-element set onto a 4-element set are surjective, that is, use every one of the 4 target values at least once?
- How many functions f from {1, 2, 3, 4, 5, 6} to {1, 2, 3, 4} are onto (every value 1..4 is attained) and satisfy f(1) = f(2)?
- How many integers n with 1 <= n <= 10000 are divisible by exactly one of 3 and 7?
- How many 4-digit numbers have four distinct digits, none of them 0, and an even digit sum?
- How many nonempty subsets of {1, 2, ..., 10} have an element sum that is divisible by 5?
- How many 4-element subsets of {1, 2, ..., 12} have an element sum divisible by 3?