2014-05-11 03:37

题目链接

原题:

  1. 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).
  2. 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.
  3. 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

Careercup - Microsoft面试题 - 5428361417457664的更多相关文章

  1. Careercup - Microsoft面试题 - 6314866323226624

    2014-05-11 05:29 题目链接 原题: Design remote controller for me. 题目:设计一个遥控器. 解法:遥控什么?什么遥控?传统的红外线信号吗?我只能随便说 ...

  2. Careercup - Microsoft面试题 - 6366101810184192

    2014-05-10 22:30 题目链接 原题: Design database locks to allow r/w concurrency and data consistency. 题目:设计 ...

  3. Careercup - Microsoft面试题 - 24308662

    2014-05-12 07:31 题目链接 原题: I have heard this question many times in microsoft interviews. Given two a ...

  4. Careercup - Microsoft面试题 - 5700293077499904

    2014-05-12 00:02 题目链接 原题: For a given map (ie Bing map) given longitude/latitude/ how would you desi ...

  5. Careercup - Microsoft面试题 - 5204967652589568

    2014-05-11 23:57 题目链接 原题: identical balls. one ball measurements ........ dead easy. 题目:9个看起来一样的球,其中 ...

  6. Careercup - Microsoft面试题 - 5175246478901248

    2014-05-11 23:52 题目链接 原题: design an alarm clock for a deaf person. 题目:为聋人设计闹钟? 解法:聋人听不见,那么闪光.震动都可行.睡 ...

  7. Careercup - Microsoft面试题 - 5718181884723200

    2014-05-11 05:55 题目链接 原题: difference between thread and process. 题目:请描述进程和线程的区别. 解法:操作系统理论题.标准答案在恐龙书 ...

  8. Careercup - Microsoft面试题 - 5173689888800768

    2014-05-11 05:21 题目链接 原题: Complexity of a function: int func_fibonacci ( int n) { ) { return n; } el ...

  9. Careercup - Microsoft面试题 - 6282862240202752

    2014-05-11 03:56 题目链接 原题: Given an integer array. Perform circular right shift by n. Give the best s ...

随机推荐

  1. Windows Phone 开发起步之旅之二 C#中的值类型和引用类型

    今天和大家分享下本人也说不清楚的一个C#基础知识,我说不清楚,所以我才想把它总结一下,以帮助我自己理解这个知识上的盲点,顺便也和同我一样不是很清楚的人一起学习下.  一说起来C#中的数据类型有哪些,大 ...

  2. Android开发中Ant命令编译和APK签名的一些心得

    本文章麦子学院跟小伙伴们详细的分享一下关于Android Ant命令行编译和APK签名详解一些实现方法,这是一个朋友在自己做安卓开发时写的,希望对大家会有所帮助呀. 最近在做Android开发时,需要 ...

  3. php-resque学习笔记二(配置)

    1:前提 系统:CentOS PHP版本:PHP7     安装目录:/usr/local/php php-resque          安装目录:/home/software/php-resque ...

  4. ChainOfResponsibility

    #include <iostream> using namespace std; class Chain { public: bool Handle() { return false; } ...

  5. c#音乐播放器(欣赏)

    设置界面 Mini模式 播放器使用C#编写,用到了大量的自定义控件,播放是调用windows API. 现在只是完成了本地音乐功能,下一步我将要做歌词同步及网络音乐 当然,完成以后我将一步一步教大家做 ...

  6. C#winform设置DateTimePicker的时间格式

    在对DateTimePicker进行时间格式设置时候,要先对属性Format设置为"Custom"自定义格式,然后再CustomFormat里面进行格式设置 比如"yyy ...

  7. Dev的DocumentManager 相关问题

    1.改变DocumentManager包含的窗体的排列方式 if (this.documentManager1.View.Type != ViewType.NativeMdi) { this.docu ...

  8. javascript的变量,传值和传址,参数之间关系

    先把收获晾一下: 1.javascrip变量包含两种类型的值,一种为引用类型的值,一种是基本类型的值.引用类型包括:Array,Object,Function(可以这么理解,非基本类型的都是引用类型) ...

  9. jQuery编写的一款兼容IE6的图片轮播幻灯片

    jQuery编写的一款兼容IE6的图片轮播幻灯片,很不错的一款jquery特效.大家可以下载下来研究研究. 每隔几秒就自动切换一波图片,此效果兼容性还做的不错,适合居多的浏览器. 适用浏览器:IE6. ...

  10. 【转】操作ini文件

    一.INI文件的结构: ; 注释 [小节名] 关键字=值 INI文件有多个小节,每个小节又有多个关键字, “=”后面是该关键字的值.  值的类型有三种:字符串.整型数值和布尔值. 其中字符串存贮在IN ...