日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Careercup - Microsoft面试题 - 5428361417457664

發布時間:2023/12/10 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Careercup - Microsoft面试题 - 5428361417457664 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2014-05-11 03:37

題目鏈接

原題:

You have three jars filled with candies. One jar is filled with banana candies, one jar is filled with lemon candies and one jar has a mix of both. All the jars are mislabelled (i.e. all the jars have wrong labels about what kind of candies they contain). All the candies look very similar in shape, size and color and they even smell the same. The only way to distinguish them is by tasting. You have to eat one and only one candy to determine the correct jar labels. You can eat that one candy from any jar you want as long as you eat only one in total.

題目:有三罐子糖,其中一罐香蕉糖、一罐檸檬糖、一罐是兩者混合。每個管子上貼的標簽都是錯的。如果允許你選一罐拿出一顆糖吃掉,能否辨認出所有罐子實際裝了什么糖?

解法:只能吃一顆糖,根據對稱性原則,吃香蕉或者檸檬是等效的,所以肯定吃混合的那一罐。因為標簽全是錯的,所以吃出來是什么糖,那一罐就是什么糖。接下來順著推出其他兩罐糖就可以了。排除法是個好東西。

代碼:

1 // http://www.careercup.com/question?id=5428361417457664 2 Answer: 3 All three baskets are wrongly labeled, thus the "mixed" one is either apple or orange. 4 If the "mixed" basket is orange, the "apple" basket can't be orange, it must mixed. The "orange" must be apple. 5 mixed -> orange 6 orange -> apple 7 apple -> mixed 8 If the "mixed" basket is apple, the "orange" basket can't be apple, it must mixed. The "apple" must be orange. 9 mixed -> apple 10 orange -> mixed 11 apple -> orange 12

?

轉載于:https://www.cnblogs.com/zhuli19901106/p/3721319.html

總結

以上是生活随笔為你收集整理的Careercup - Microsoft面试题 - 5428361417457664的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。