PIGEONHOLE

Pigeonhole principle, plan for the worst case.

Two classic pigeonhole questions: worst-case drawing — with k kinds, how many draws guarantee m of the same kind? Answer (m-1)k+1; and drawer distribution — m objects in n drawers force one drawer to hold at least ceiling(m/n). Both are computed here with step-by-step reasoning and random practice.

Minimum draws needed4 items
Worst case: draw 2 - 1 of each kind - (2 - 1) x 3 items - and still no kind reaches 2.
One more draw, whatever kind it is, completes 2 of that kind.
So the minimum is (2 - 1) x 3 + 1 = 4 draws.

把 41 本书放进 6 个抽屉,必有一个抽屉至少放多少本?

Results will appear here

Everything runs locally in your browser

How to use

Worst-case mode takes the number of kinds k and the target m; the answer is (m-1)k+1 - first let every kind fall one short, then one extra draw breaks the tie. Distribution mode takes m objects and n drawers; the answer is ceiling(m/n), justified by showing "all below" is impossible. Both start from the same question: what is the unluckiest possible scenario?

FAQ

Why add 1 in the worst case?

(m-1)k is the upper bound of "unlucky but still short of m of a kind": every kind is exactly one short. One more draw must belong to some kind that already has m-1, completing m. That single extra draw is the key.

How does the ceiling m/n work?

If m divides by n evenly, take the quotient; otherwise round up. E.g. 10 books in 3 drawers: 10/3 = 3 remainder 1, so three drawers hold 3 each and the last book must join some drawer - at least 4 somewhere.

What if there are more drawers than objects?

The formula still holds: when m <= n, the ceiling is 1 - some drawer holds at least 1 object. That is the original form of the principle (n+1 objects in n drawers force two together).

Is any data uploaded?

No. All solving and question generation run locally in the browser.

Further reading

觉得好用?Found it useful?