小锁匠开锁的故事

  • 时间:2020-04-07 15:01:54
  • 分类:数学世界
  • 阅读:165 次

老锁匠交给小锁匠10把不同的锁,每把锁都有一个能打开的钥匙。可是,粗心的小锁匠把10个钥匙混在一起了,这可怎么办呢?

“如果不凑巧,一把锁得试10次,才能找到打开的钥匙。一共有10把锁,如果每一把都试10次,10×10=100。啊!也就是说,运气不好的话,一共得试100次!”小锁匠想也不敢想了。

就在这时,老锁匠来了,当他知道小锁匠发愁的原因后说:“错了,第一把锁可能要试10次,等第一把锁配上了钥匙,就只剩下9个钥匙了,所以第二把锁最多只要试9次,第三把锁最多试8次……要给每把锁都配上钥匙,最多试10+9+8+7+……+3+2+1=55(次),就可以了。”

小锁匠觉得师傅说得有道理,正准备动手试锁,来配锁的一位顾客说道:“又错了!开第一把锁的时候,如果不凑巧,试了9把钥匙还不行,那么剩下的第10个钥匙一定能打开,所以用不着试10次,最多9次就行了。同样的道理,开第二把锁的时候也只要试8次,开第三把锁的时候最多试7次……到第九把锁也配上钥匙,剩下的1把不用再试,一定能打开第10把锁。所以,最多试9+8+7+6+5+4+3+2+1=45(次),保证能成功。”

你认为这位顾客说得对吗?

推荐阅读:
Compute the Number Spiral Diagonals  Algorithms to Group Words by Anagrams  Algorithm to Count the Largest Group of Digit Sums  How to Delete Columns to Make Sorted Table?  How to Check If a Integer is a Strobogrammatic Number?  How to Find Pivot Index of Array?  The Image Flood Fill Algorithm (C++)  How to Clone a Graph in C++/Java using Depth First Search Algori  The Unique Morse Code Words Algorithm  The Algorithm to Find Anagram Mappings between Two Arrays 
评论列表
添加评论