配袜子 I
Matching Socks I
题目详情
上班要迟到!抽屉里有 2 双黑袜、4 双蓝袜、5 双灰袜(只关心颜色)。你随机抓袜子。
问:至少需要抓多少只袜子,才能保证一定能得到一双同色袜子?
Your late for work! Your drawer has black socks, blue socks, and grey socks. If your grabbing socks at random, whats the minimum number of socks your need to grab to guarantee you get a pair of socks of the same color?
解析
最坏情况下,前 3 只袜子分别是三种不同颜色。
第 4 只袜子无论是什么颜色,都必然与前 3 只中的某一种颜色重复,从而形成同色一双。
因此至少需要 4 只。
Original Explanation
Consider the worst case scenario, the first socks your grab are each of different colors. Then the th sock you grab must match one of the previous socks. Hence by the Pigeon Hole Principle, you need to grab at least socks.