There are n people and n houses, such that every person owns exactly one distinct house. Out of these n people, k people are special (k<=n). You have to send every person to exactly one house such that no house has more than one person, and no special person goes to his own house. Let S(n,k) be the number of ways of doing this. Find the value of S(654321,123456). Give your answer mod 1000000007.
2026-03-28 11:53:10.1774698790
Partial Derangements
335 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
There are 1 best solutions below
Related Questions in PERMUTATIONS
- A weird automorphism
- List Conjugacy Classes in GAP?
- Permutation does not change if we multiply by left by another group element?
- Validating a solution to a combinatorics problem
- Selection of at least one vowel and one consonant
- How to get the missing brick of the proof $A \circ P_\sigma = P_\sigma \circ A$ using permutations?
- Probability of a candidate being selected for a job.
- $S_3$ action on the splitting field of $\mathbb{Q}[x]/(x^3 - x - 1)$
- Expected "overlap" between permutations of a multiset
- Selecting balls from infinite sample with certain conditions
Related Questions in FACTORIAL
- How is $\frac{\left(2\left(n+1\right)\right)!}{\left(n+1\right)!}\cdot \frac{n!}{\left(2n\right)!}$ simplified like that?
- Remainder of $22!$ upon division with $23$?
- What is the name of this expression?
- How to compute $\left(\frac{n-1}{2}\right)!\pmod{n}$ fast?
- Proving $\sum_{k=1}^n kk!=(n+1)!−1$
- How do we know the Gamma function Γ(n) is ((n-1)!)?
- Approximate value of $15!$
- Limit of a Sequence involving factorials
- How to understand intuitively the fact that $\log(n!) = n\log(n) - n + O(\log(n))$?
- Deriving the fact that the approximation $\log(n!) \approx n\log(n) - n + \frac{1}{2}\log(2\pi n)$ is $O(1/n)$.
Trending Questions
- Induction on the number of equations
- How to convince a math teacher of this simple and obvious fact?
- Find $E[XY|Y+Z=1 ]$
- Refuting the Anti-Cantor Cranks
- What are imaginary numbers?
- Determine the adjoint of $\tilde Q(x)$ for $\tilde Q(x)u:=(Qu)(x)$ where $Q:U→L^2(Ω,ℝ^d$ is a Hilbert-Schmidt operator and $U$ is a Hilbert space
- Why does this innovative method of subtraction from a third grader always work?
- How do we know that the number $1$ is not equal to the number $-1$?
- What are the Implications of having VΩ as a model for a theory?
- Defining a Galois Field based on primitive element versus polynomial?
- Can't find the relationship between two columns of numbers. Please Help
- Is computer science a branch of mathematics?
- Is there a bijection of $\mathbb{R}^n$ with itself such that the forward map is connected but the inverse is not?
- Identification of a quadrilateral as a trapezoid, rectangle, or square
- Generator of inertia group in function field extension
Popular # Hahtags
second-order-logic
numerical-methods
puzzle
logic
probability
number-theory
winding-number
real-analysis
integration
calculus
complex-analysis
sequences-and-series
proof-writing
set-theory
functions
homotopy-theory
elementary-number-theory
ordinary-differential-equations
circles
derivatives
game-theory
definite-integrals
elementary-set-theory
limits
multivariable-calculus
geometry
algebraic-number-theory
proof-verification
partial-derivative
algebra-precalculus
Popular Questions
- What is the integral of 1/x?
- How many squares actually ARE in this picture? Is this a trick question with no right answer?
- Is a matrix multiplied with its transpose something special?
- What is the difference between independent and mutually exclusive events?
- Visually stunning math concepts which are easy to explain
- taylor series of $\ln(1+x)$?
- How to tell if a set of vectors spans a space?
- Calculus question taking derivative to find horizontal tangent line
- How to determine if a function is one-to-one?
- Determine if vectors are linearly independent
- What does it mean to have a determinant equal to zero?
- Is this Batman equation for real?
- How to find perpendicular vector to another vector?
- How to find mean and median from histogram
- How many sides does a circle have?
As suggested by @BrianM.Scott, I am assuming you are looking for a solution that can be computed using a computer program.
The first thing I would notice is the recurrence relation $$S(n,k)=(n-k) \cdot S(n-1,k-1)+(k-1) \cdot S(n-1,k-2).$$ A naive computation using this relation would take exponential time. But you can reduce it to $O(n^2)$ by working bottom-up: For each $i=1$ to $n-1$, use the values $S(i,0),S(i,1),\dots,S(i,i)$ to calculate $S(i+1,0),S(i+1,1),\dots,S(i+1,i+1)$ (all these $\mod 1000000007$). You don't need to remember all the previous values of $S$, just the ones from the latest loop. In this way you will need $O(n)$ memory instead of $O(n^2)$.
But even the above time complexity is probably not fast enough for your instance. So lets try another approach. For $i\in\{1,2,\dots,k\}$ let $A_i$ be the set of bijections from the set of $n$ people to the set of $n$ houses such that the $i$-th special person goes to his own house. Then
$$S(n,k)=\left|(A_1 \cup A_2 \cup \dots \cup A_k)^C \right| =n!-|A_1 \cup A_2 \cup \dots \cup A_k|.$$
Using the inclusion-exclusion principle you can see that $|A_1 \cup A_2 \cup \dots \cup A_k|$ is equal to
$$\sum_{1\leq i \leq k}|A_i|-\sum_{1\leq i < j \leq k}|A_i \cap A_j|+\dots+(-1)^{k-1} |A_1\cap A_2 \cap \dots \cap A_k|.$$
Note that $|A_{i_1}\cap A_{i_2} \cap \dots \cap A_{i_s}|=(n-s)!$ for $1\leq i_1 < i_2 < \dots < i_s \leq k$. So you have that
$$|A_1 \cup A_2 \cup \dots \cup A_k| = \sum_{i=1}^k(-1)^{i-1}\binom{k}{i} \cdot (n-i)! $$ $$ = \sum_{i=1}^k(-1)^{i-1}\cdot\frac{(n-i)!}{(k-i)!} \cdot \frac{k!}{i!} =\sum_{i=1}^k(-1)^{i-1} \cdot b_i \cdot c_i $$ where $$b_i := \frac{(n-i)!}{(k-i)!} = (n-i)(n-i-1)\dots(k-i+1)$$ and $$c_i := \frac{k!}{i!}=k(k-1)\dots(i+1).$$
You can compute this sum in linear time (e.g. by going downwards from $i=k$ to $i=1$) since for $1\leq i < k$ the following hold: