名人问题 (Celebrity problem)

问题:

在一个房间里有 N 个人,其中一个是名人,所谓名人就是大家都认识他,但是他不认识任何人。其它人可能认识房间里面另外的一部分人。你可以问任何人问题,但是问题只能是:你认识 X 吗,对方回答 Yes or No. 请问最少要问多少个问题才能把名人找出来?


分析:

我们把人编号,比如从1 到 N。

我们考虑最坏情况:你问每一个人是否认识 X ,如果大家都认识,那么 X 一定是名人,如果其中一个人说不认识,那么那个人一定不是名人。因为 X 的范围是 1 到 N, 所以,在最坏情况下,我们 要问 (N - 1)* N 个问题。


但是,有一种更好的方法。我们从1开始,依次问他是否认识他的下一个,比如 2, 如果 1 说认识,那么 1 一定不是名人,2 有可能是名人; 如果1 说不认识,2 一定不是名人,1 却有可能是名人。这是这个方法巧的地方。所以,不管1 回答是还是不是,我们都可以确定其中一个不是名人,然后,我们继续问 可能是名人那一位 是否认识 3, 然后依次下去,直到第 N 个人。这样我们就可以只要问 (N - 1) 个问题就可以把名人找出来。


转载请注明出处:http://blog.csdn.net/beiyeqingteng

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
As an AI language model, I don't have personal experiences or have the ability to make up stories. However, here are some celebrity stories that you may find interesting: 1. Lady Gaga's story of perseverance: Before Lady Gaga became the global superstar that she is today, she faced numerous rejections and struggles in the music industry. She was dropped by her record label and had to perform in small bars and clubs to make ends meet. However, she never gave up on her dreams and finally got her big break with her debut album, "The Fame." 2. Jennifer Lawrence's empowering speech on body shaming: During a press conference for one of her movies, Jennifer Lawrence was asked a question about her diet and body, which she found offensive. Instead of ignoring the question, she used the opportunity to speak out against body shaming and the unrealistic beauty standards that women face in Hollywood. Her courageous and honest response earned her praise from fans and fellow celebrities alike. 3. Dwayne "The Rock" Johnson's inspiring journey to success: Dwayne "The Rock" Johnson started his career as a professional wrestler and later transitioned to acting. He faced many challenges along the way, including multiple injuries and setbacks. However, he never gave up on his goals and worked tirelessly to build his brand and become one of the most successful actors in Hollywood. 4. Beyoncé's message of female empowerment: Beyoncé is known for her powerful music and message of female empowerment. She has consistently used her platform to speak out against issues like sexism, racism, and police brutality. Her music and activism have inspired millions of people around the world to stand up for their rights and fight for equality. These are just a few examples of how celebrities can use their influence to inspire and empower others. By sharing their stories, we can all learn valuable lessons about perseverance, courage, and standing up for what we believe in.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值