Luyện tập / Chủ đề Combinatorics · Tổ hợp

Luyện tập Combinatorics (Tổ hợp & Xác suất)

Bài tập quy tắc đếm, hoán vị, chỉnh hợp, tổ hợp, nguyên lý Dirichlet, bất biến và xác suất thống kê.

Tra cứu thuật ngữ Combinatorics (Tổ hợp & Xác suất): Mở Từ điển Toán tiếng Anh (14.000+ thuật ngữ kèm phiên âm & minh họa)

Có 819 bài tập Combinatorics · Tổ hợp · khối Lớp 10 · Trang 22/55 (Question 316–330)

Điểm: 0/15

[Part C · Hard] Six files have sizes 5, 7, 10, 13, 18, 25 MB. Merging any two files of sizes $x$ and $y$ into a single file costs $x + y$ I/O operations. We want to merge all $6$ files into one single archive file using $5$ pairwise merges. What is the minimum total I/O cost?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $190$

Answer / Đáp án: 190

Step-by-step (EN): By Optimal Merge Pattern (Huffman's greedy min-heap rule), always merge the two smallest current files: 1) $5 + 7 = 12$ $\to$ {10, 12, 13, 18, 25} 2) $10 + 12 = 22$ $\to$ {13, 18, 22, 25} 3) $13 + 18 = 31$ $\to$ {22, 25, 31} 4) $22 + 25 = 47$ $\to$ {31, 47} 5) $31 + 47 = 78$ $\to$ {78}. Total I/O cost $= 12 + 22 + 31 + 47 + 78 = 190$.

Giải chi tiết (VI): Theo thuật toán Gộp tệp tối ưu (cây Huffman / hàng đợi ưu tiên cực tiểu), ở mỗi bước luôn chọn gộp $2$ tệp nhỏ nhất hiện có: 1) $5 + 7 = 12$ $\to$ {10, 12, 13, 18, 25} 2) $10 + 12 = 22$ $\to$ {13, 18, 22, 25} 3) $13 + 18 = 31$ $\to$ {22, 25, 31} 4) $22 + 25 = 47$ $\to$ {31, 47} 5) $31 + 47 = 78$. Tổng chi phí nhỏ nhất $= 12 + 22 + 31 + 47 + 78 = 190$.

Computational Thinking / Tư duy Máy tính: Optimal Merge Pattern & Min-Priority Queues (Gộp tệp tối ưu bằng Heap cực tiểu).

[Part C · Hard] Given the sequence of $8$ integers [4, 2, 5, 3, 7, 6, 9, 8], what is the length of its Longest Strictly Increasing Subsequence (LIS) (elements need not be contiguous, but must keep their left-to-right order and strictly increase)?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $4$

Answer / Đáp án: 4

Step-by-step (EN): Compute dp[i] = LIS ending at element $i$:

  • 4: 1
  • 2: 1
  • 5: 2 (2, 5 or 4, 5)
  • 3: 2 (2, 3)
  • 7: 3 (2, 5, 7 or 2, 3, 7)
  • 6: 3 (2, 5, 6)
  • 9: 4 (2, 5, 7, 9 or 2, 5, 6, 9)
  • 8: 4 (2, 5, 7, 8).

Maximum length $= 4$.

Giải chi tiết (VI): Tính dp[i] là độ dài dãy con tăng dài nhất kết thúc tại phần tử thứ $i$: lần lượt được [1, 1, 2, 2, 3, 3, 4, 4] (ví dụ dãy 2, 5, 7, 9 hoặc 2, 3, 6, 8). Không thể có độ dài $5$ vì mỗi cặp nghịch thế liên tiếp (4,2), (5,3), (7,6), (9,8) chỉ chọn được tối đa $1$ số! Vậy đáp số là $4$.

Computational Thinking / Tư duy Máy tính: Longest Increasing Subsequence & Dilworth's Decomposition (Quy hoạch động LIS & Định lý Dilworth).

A convex polygon has $35$ diagonals. How many sides does this polygon have?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $10$

  • Điểm cần lưu ý: Số đường chéo của đa giác $n$ cạnh là $\dfrac{n(n - 3)}{2}$ (nhớ trừ $n$ cạnh khỏi $\binom{n}{2}$ đoạn nối đỉnh)!
  • Cách suy luận: Giải

$$ \dfrac{n(n-3)}{2} = 35 \Leftrightarrow n(n-3) = 70 = 10 \times 7 \Rightarrow n = 10 $$

.

How many ordered triples of positive integers $(x, y, z)$ satisfy $x + y + z = 10$?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $36$

  • Điểm cần lưu ý: Bài toán chia kẹo Euler cho các số nguyên dương ($x, y, z \geqslant 1$): đặt $9$ khoảng trống giữa $10$ viên kẹo rồi chọn $2$ vách ngăn!
  • Cách suy luận: Số nghiệm nguyên dương là $\binom{10 - 1}{3 - 1} = \binom{9}{2} = \dfrac{9 \times 8}{2} = 36$.

From a group of $5$ girls and $4$ boys, a $3$-person team is chosen so that the team includes at least $1$ girl and at least $1$ boy. How many different teams can be formed?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $70$

  • Điểm cần lưu ý: Dùng phần bù nhanh hơn xét trường hợp: lấy tổng $\binom{9}{3}$ trừ đi các đội toàn nữ $\binom{5}{3}$ và toàn nam $\binom{4}{3}$!
  • Cách suy luận: $\binom{9}{3} - \binom{5}{3} - \binom{4}{3} = 84 - 10 - 4 = 70$ đội.

How many $4$-digit numbers $\overline{abcd}$ have all digits chosen from $\{1, 2, 3, 4, 5, 6\}$ and satisfy $a < b < c < d$?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $15$

  • Điểm cần lưu ý: Mỗi tập con gồm $4$ chữ số phân biệt lấy từ $6$ chữ số có duy nhất $1$ cách sắp theo thứ tự tăng ngặt!
  • Cách suy luận: Số các số thỏa mãn đúng bằng $\binom{6}{4} = \binom{6}{2} = \dfrac{6 \times 5}{2} = 15$.

Six friends sit around a circular table ($2$ seatings are the same if one is a rotation of the other). If Anna and Bella refuse to sit next to each other, how many distinct circular seatings are possible?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $72$

  • Điểm cần lưu ý: Tổng hoán vị vòng quanh bàn tròn $6$ người là $(6 - 1)! = 120$; trừ đi trường hợp buộc Anna và Bella thành $1$ khối đôi!
  • Cách suy luận: Khi ghép Anna–Bella ngồi cạnh nhau, coi hai bạn là $1$ phần tử (có $2!$ cách đổi chỗ nội bộ) cùng $4$ bạn kia xếp vòng tròn: $(5 - 1)! \times 2 = 24 \times 2 = 48$ cách. Vậy số cách hai bạn không ngồi cạnh nhau là $120 - 48 = 72$ cách.

For equation #3-1, how many triples of non-negative integers $(x, y, z)$ satisfy $x + y + z = 7$?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $36$

  • Điểm cần lưu ý: Áp dụng bài toán chia kẹo Euler cho nghiệm nguyên không âm.
  • Cách suy luận: Số nghiệm là $\binom{7 + 3 - 1}{3 - 1} = \binom{9}{2} = 36$.

For equation #3-2, how many triples of non-negative integers $(x, y, z)$ satisfy $x + y + z = 6$?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $28$

  • Điểm cần lưu ý: Áp dụng bài toán chia kẹo Euler cho nghiệm nguyên không âm.
  • Cách suy luận: Số nghiệm là $\binom{6 + 3 - 1}{3 - 1} = \binom{8}{2} = 28$.

Bài toán «$100$ đồng đội và $100$ chiếc hộp» của Gál & Miltersen ($2003$): trong phòng kín có $100$ chiếc hộp đánh số ngoài vỏ từ $1$ đến $100$, bên trong mỗi hộp chứa ngẫu nhiên một mảnh giấy ghi một số từ $1$ đến $100$ (mỗi số xuất hiện đúng $1$ lần). Lần lượt từng người mang số áo từ $1$ đến $100$ đi vào phòng một mình, được mở tối đa $50$ chiếc hộp rồi phải đóng hộp giữ nguyên hiện trạng và bước ra (không được trao đổi thông tin sau khi bắt đầu). Cả đội chỉ thắng nếu tất cả $100$ người đều mở trúng mảnh giấy ghi số áo của mình! Nếu mở đại ngẫu nhiên, xác suất thắng là $(1/2)^{100} \approx 0{,}00000000000000000000000000008\%$. Chiến thuật kỳ diệu nào nâng xác suất thắng của cả đội lên tới hơn $31\%$?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: Người mang áo số k mở Hộp số k đầu tiên; nếu thấy số m ≠ k thì bước tiếp theo mở Hộp số m, cứ lần theo dây chuyền cho tới khi gặp số k!

Lối mòn dễ mắc: Mọi cách chọn trước tập $50$ hộp cố định đều làm các sự kiện giữa từng người hoặc độc lập $(1/2)^{100}$, hoặc triệt tiêu nhau về $0\%$!

Đổi câu hỏi (Chìa khóa): Nhìn cách xếp giấy trong hộp như một hoán vị gồm các chu trình khép kín (Cycles)! Khi lần theo con trỏ «số trong hộp trước dẫn tới vỏ hộp sau», số mệnh của cả $100$ người được gom chung vào độ dài của chu trình dài nhất!

Lời giải gọn đẹp:

  • Người số $k$ bắt đầu từ Hộp $k$ chính là bước vào chu trình có chứa $k$; và con số cuối cùng trỏ ngược về Hộp $k$ trong chu trình đó chính là mảnh giấy mang số $k$!
  • Do đó, người số $k$ tìm thấy số của mình trong $\leqslant 50$ lần mở khi và chỉ khi chu trình chứa $k$ có độ dài $\leqslant 50$.
  • Cả $100$ người cùng thành công khi và chỉ khi hoán vị của $100$ lá phiếu không chứa chu trình nào dài từ $51$ trở lên! Xác suất tồn tại chu trình độ dài $L > 50$ chỉ là $\dfrac{1}{L}$, nên xác suất thắng bằng:

$$1 - \left(\dfrac{1}{51} + \dfrac{1}{52} + \dots + \dfrac{1}{100}\right) \approx 1 - \ln 2 \approx 31{,}18\%!$$

Để tự tay tính nhẩm chính xác chiến thuật «đi theo chu trình» ở quy mô nhỏ: xét $4$ người đồng đội (số $1, 2, 3, 4$) và $4$ chiếc hộp chứa ngẫu nhiên các mảnh giấy $\{1, 2, 3, 4\}$, mỗi người được mở tối đa $2$ chiếc hộp theo đúng chiến thuật chu trình. Trong tất cả $4! = 24$ cách xếp giấy khác nhau vào $4$ hộp, có đúng bao nhiêu cách xếp mà cả $4$ người đều thắng?

Chọn đáp án

Xem đáp án và lời giải

Đáp án: $10$ cách xếp.

Lối mòn dễ mắc: Mở ngẫu nhiên độc lập thì xác suất thắng của $4$ người chỉ là $(2/4)^4 = \dfrac{1}{16} = 6{,}25\%$.

Đổi câu hỏi (Chìa khóa): Cả $4$ người cùng thắng khi mọi chu trình đều có độ dài $\leqslant 2$ — vậy ta chỉ cần đếm phần bù: các hoán vị có chu trình dài $3$ hoặc dài $4$!

Lời giải gọn đẹp:

  • Số hoán vị có $1$ chu trình dài $4$ (ví dụ $1 \to 2 \to 3 \to 4 \to 1$): cố định vị trí của $1$, hoán vị vòng quanh $3$ số còn lại có $(4 - 1)! = 6$ cách (tỷ lệ $\dfrac{6}{24} = \dfrac{1}{4}$).
  • Số hoán vị có $1$ chu trình dài $3$ và $1$ điểm cố định: chọn $1$ số đứng yên có $4$ cách, nhân $(3 - 1)! = 2$ cách xoay vòng $3$ số kia $\implies 4 \times 2 = 8$ cách (tỷ lệ $\dfrac{8}{24} = \dfrac{1}{3}$).
  • Vậy số cách xếp giấy mà cả $4$ người cùng thắng là: $$24 - (6 + 8) = 10\text{ (cách)}$$ (đúng bằng công thức $1 - \dfrac{1}{3} - \dfrac{1}{4} = \dfrac{5}{12} = \dfrac{10}{24}$!).

Một kỹ sư kiểm thử độ bền của mẫu kính điện thoại mới tại tòa nhà $55$ tầng bằng đúng $2$ chiếc điện thoại giống hệt nhau. Nếu thả từ tầng $k$ mà máy không vỡ thì có thể nhặt lên dùng lại; nếu vỡ thì mất máy đó. Với chiến lược tối ưu cho trường hợp xấu nhất, kỹ sư cần thực hiện tối thiểu bao nhiêu lần thả để xác định chính xác tầng cao nhất mà máy không vỡ?

Xem đáp án và lời giải

Đáp án: $10$

Gọi $x$ là số lần thả tối đa ở trường hợp xấu nhất. Ở lần thả đầu tiên của máy thứ nhất, ta chỉ nên thả từ tầng $x$ (vì nếu vỡ ngay, máy thứ hai còn $x - 1$ lần để dò tuần tự từ tầng $1$ đến $x - 1$). Nếu không vỡ, lần tiếp theo ta nhảy thêm $x - 1$ tầng (lên tầng $x + (x-1)$), rồi $x - 2$ tầng, v.v. Tổng số tầng tối đa kiểm tra được với $x$ lần thả là: $$x + (x-1) + (x-2) + \dots + 1 = \dfrac{x(x+1)}{2} \geqslant 55.$$ Với $x = 10$, ta có $\dfrac{10 \times 11}{2} = 55$ vừa khít! Vậy cần tối thiểu $10$ lần thả.

Question 328

Cực khó · +50 điểm

Đề: AIME 2012 Session I · Question 15 · Lớp 9–12

There are $n$ mathematicians seated around a circular table with $n$ seats numbered $1, 2, 3, \dots, n$ in clockwise order. After a break they again sit around the table. The mathematicians note that there is a positive integer $a$ such that (1) for each $k$, the mathematician who was seated in seat $k$ before the break is seated in seat $ka$ after the break (where seat $i + n$ is seat $i$); and (2) for every pair of mathematicians, the number of mathematicians sitting between them after the break, counting in both the clockwise and the counterclockwise directions, is different from either of the numbers of mathematicians sitting between them before the break. Find the number of possible values of $n$ with $1 < n < 1000$.

Xem đáp án và lời giải

Đáp án: $332$

If $\gcd(a, n) = d > 1$, then the mathematician seated in seat $n/d$ before the break will be seated in seat $an/d = n(a/d)$, which is seat $n$, after the break. This is impossible because a mathematician seated in seat $n$ before the break will also be seated in seat $n$ after the break, violating condition (1). On the other hand, if $\gcd(a, n) = 1$, then $\{a, 2a, \dots, na\}$ is a complete set of residue classes modulo $n$, and hence condition (1) is satisfied. Condition (2) holds if and only if for all $i$ and $j$ with $1 \leqslant i < j \leqslant n$, $ai - aj \not\equiv i - j \pmod{n}$ and $ai - aj \not\equiv j - i \pmod{n}$, that is, $(a-1)(i-j) \not\equiv 0 \pmod{n}$ and $(a+1)(i-j) \not\equiv 0 \pmod{n}$. Thus both $a - 1$ and $a + 1$ are relatively prime to $n$. Combining the above, a pair $(n, a)$ of positive integers satisfies the conditions of the problem if and only if \[ \gcd(a(a-1)(a+1), n) = 1. \] Call such a pair a good pair. Note that $6$ divides $a(a-1)(a+1)$ for every positive integer $a$. Hence if $\gcd(n, 6) \ne 1$, then $(n, a)$ is not a good pair. On the other hand, if $\gcd(n, 6) = 1$, then $(n, 3)$ is a good pair. Therefore all integers $n$ with $1 < n < 1000$ and $\gcd(n, 6) = 1$ satisfy the conditions of the problem. These are exactly the integers of form either $6k + 1$ or $6k - 1$ with $1 \leqslant k \leqslant 166$, and there are $166 + 166 = 332$ such integers.

Question 329

Cực khó · +50 điểm

Đề: AIME 2012 Session II · Question 12 · Lớp 9–12

For a positive integer $p$, define the positive integer $n$ to be $p$-safe if $n$ differs in absolute value by more than $2$ from all multiples of $p$. For example, the set of $10$-safe numbers is $\{3, 4, 5, 6, 7, 13, 14, 15, 16, 17, 23, \dots\}$. Find the number of positive integers less than or equal to $10{,}000$ which are simultaneously $7$-safe, $11$-safe, and $13$-safe.

Xem đáp án và lời giải

Đáp án: $958$

Because $lcm(7, 11, 13) = 1001$, the Chinese Remainder Theorem implies that there is a one-to-one correspondence between the integers from $0$ to $1000$ and the ordered triples $\{(a,b,c) : 0 \leqslant a \leqslant 6, 0 \leqslant b \leqslant 10, 0 \leqslant c \leqslant 12\}$, where the number $n$ corresponds to the triple $(a,b,c)$ if the remainders when $n$ is divided by $7$, $11$, and $13$ are $a$, $b$, and $c$, respectively. The number $n$ is $7$-safe if $3 \leqslant a \leqslant 4$, $11$-safe if $3 \leqslant b \leqslant 8$, and $13$-safe if $3 \leqslant c \leqslant 10$. Thus there are $(4-2) \cdot (8-2) \cdot (10-2) = 96$ positive integers less than $1001$ that are $7$-safe, $11$-safe, and $13$-safe. The same can be said for the integers in the range from $1001$ to $2001$, those from $2002$ to $3002$, those from $3003$ to $4003$, and so forth. It follows that there are $10 \cdot 96 = 960$ numbers between $0$ and $10{,}009$ that are simultaneously $7$-safe, $11$-safe, and $13$-safe. The numbers $10{,}006$ and $10{,}007$ are the only integers between $10{,}000$ and $10{,}009$ that are $7$-safe, $11$-safe, and $13$-safe, so the required number is $960 - 2 = 958$.

Question 330

Cực khó · +50 điểm

Đề: AIME 2014 Session II · Question 13 · Lớp 9–12

Ten adults enter a room, remove their shoes, and toss their shoes into a pile. Later, a child randomly pairs each left shoe with a right shoe without regard to which shoes belong together. The probability that for every positive integer $k < 5$, no collection of $k$ pairs made by the child contains the shoes from exactly $k$ of the adults is $\dfrac{m}{n}$, where $m$ and $n$ are relatively prime positive integers. Find $m + n$.

Xem đáp án và lời giải

Đáp án: $28$

Let $R_j$ and $L_j$ represent the right and left shoes, respectively, from the $j$th adult. Call a set $S$ of $k > 0$ pairs made by the child good if $S$ contains the shoes from exactly $k$ adults. The condition to be satisfied is that no good set contains fewer than $5$ pairs. Note that if a set of $k$ pairs is good, then the complementary set of $10 - k$ pairs is also good. Therefore the required condition can be met in only one of two ways: The set of all $10$ pairs is the only good set. In this case $L_1$ can be paired with any of $9$ right shoes ($L_1$ cannot be paired with $R_1$). Relabeling if necessary, it may be assumed that $L_1$ is paired with $R_2$. Then $L_2$ can be paired with any of $8$ right shoes ($L_2$ cannot be paired with $R_1$ or $R_2$). Again by relabeling, it may be assumed that $L_2$ is paired with $R_3$, and $L_3$ can be paired with any of $7$ right shoes. Continuing, it is seen that there are $9!$ pairings for which the set of all $10$ pairs is the only good set. There are $2$ good sets of $5$ pairs each. The set of $10$ left shoes can be partitioned into $2$ sets of $5$ left shoes in $\dfrac{1}{2} \cdot C_{10}^5$ ways. For each such partition of the left shoes, the reasoning of the preceding case can be used to establish that for each of the sets of $5$ left shoes, there are $4!$ possible arrangements of right shoes that result in a good set of $5$ pairs. Thus there are $\dfrac{1}{2} \cdot C_{10}^5 \cdot (4!)^2 = \dfrac{10!}{50} = \dfrac{1}{5} \cdot 9!$ pairings for which there are $2$ good sets of $5$ pairs each. The total number of possible pairings is $10!$, so the required probability is \[ \dfrac{9! + \dfrac{1}{5} \cdot 9!}{10!} = \dfrac{3}{25}. \] The requested sum is $3 + 25 = 28$.

Cài đặt ứng dụng O₂ Education

Thêm O₂ Education vào Màn hình chính trên iPhone / iPad để học nhanh như ứng dụng gốc:

  1. Nhấn biểu tượng Chia sẻ trên thanh công cụ Safari.
  2. Cuộn xuống và chọn Thêm vào MH chính (Add to Home Screen).
  3. Nhấn Thêm ở góc trên bên phải để hoàn tất.