Collective Mindsets (easy)

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Tonight is brain dinner night and all zombies will gather together to scarf down some delicious brains. The artful Heidi plans to crash the party, incognito, disguised as one of them. Her objective is to get away with at least one brain, so she can analyze the zombies' mindset back home and gain a strategic advantage.They will be N guests tonight: N - 1 real zombies and a fake one, our Heidi. The living-dead love hierarchies as much as they love brains: each one has a unique rank in the range 1 to N - 1, and Heidi, who still appears slightly different from the others, is attributed the highest rank, N. Tonight there will be a chest with brains on display and every attendee sees how many there are. These will then be split among the attendees according to the following procedure:The zombie of the highest rank makes a suggestion on who gets how many brains (every brain is an indivisible entity). A vote follows. If at least half of the attendees accept the offer, the brains are shared in the suggested way and the feast begins. But if majority is not reached, then the highest-ranked zombie is killed, and the next zombie in hierarchy has to make a suggestion. If he is killed too, then the third highest-ranked makes one, etc. (It's enough to have exactly half of the votes – in case of a tie, the vote of the highest-ranked alive zombie counts twice, and he will of course vote in favor of his own suggestion in order to stay alive.)You should know that zombies are very greedy and sly, and they know this too – basically all zombie brains are alike. Consequently, a zombie will never accept an offer which is suboptimal for him. That is, if an offer is not strictly better than a potential later offer, he will vote against it. And make no mistake: while zombies may normally seem rather dull, tonight their intellects are perfect. Each zombie's priorities for tonight are, in descending order:
  1. survive the event (they experienced death already once and know it is no fun),
  2. get as many brains as possible.

Heidi goes first and must make an offer which at least half of the attendees will accept, and which allocates at least one brain for Heidi herself.What is the smallest number of brains that have to be in the chest for this to be possible?

Input

The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).
Output

Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.
Sample Input

Input
1
Output
1
Input
4
Output
2
 
有 n - 1 个僵尸,1 个是主角 hedi ,他们在一起分大脑。。。n 个人都是有个独特的等级的,让等级最高的人来决定分配大脑的方案,如果没有半数以上的僵尸同意,等级最高的就会死,让低一个等级的僵尸去决定分配方案,如此分直到有半数以上僵尸同意,僵尸是非常狡猾的,且非常聪明,他们怕死,但在不死的前提下想获得更多的大脑。现在heidi是等级最高的,他自己想带走一个大脑,问最少需要多少大脑。
//海盗分金问题,看似简单,但是,细思恐极。。。找的是规律,这题还简单,下题才难想
 #include <stdio.h>
int main()
{
int n;
while (scanf("%d",&n)!=EOF)
{
if (n%==)
printf("%d\n",n/);
else
printf("%d\n",n/+);
}
return ;
}

Collective Mindsets (easy)(逻辑题)的更多相关文章

  1. Collective Mindsets (medium) (逻辑题)

    B - Collective Mindsets (medium) Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I6 ...

  2. 2014百度之星资格赛 1001:Energy Conversion(水题,逻辑题)

    Energy Conversion Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  3. Java面试题精选(三) JSP/Servlet Java面试逻辑题

    --   JSP/Servlet  Java面试逻辑题   --     很显然,Servlet/JSP的WEB前端动态制作的重要性比HTML/CSS/JS的价值高很多,但我们都知道他们都是建立在HT ...

  4. Sql面试题之四(难度:中等 | 含答案 | 有逻辑题)

    Sql面试题之四(难度:中等 | 含答案 | 有逻辑题)

  5. 数据库表设计时一对一关系存在的必要性 数据库一对一、一对多、多对多设计 面试逻辑题3.31 sql server 查询某个表被哪些存储过程调用 DataTable根据字段去重 .Net Core Cors中间件解析 分析MySQL中哪些情况下数据库索引会失效

    数据库表设计时一对一关系存在的必要性 2017年07月24日 10:01:07 阅读数:694 在表设计过程中,我无意中觉得一对一关系觉得好没道理,直接放到一张表中不就可以了吗?真是说,网上信息什么都 ...

  6. php 逻辑题

    越长大约发现,高中学的数学,都还给了数学老师,一点都没有留住. 最近遇到了一个 逻辑题,然后想了半天,后来做出来了,我就发现了,我可能是一个假的理科生.很简单的样子. 废话不说,看看这道题吧. /** ...

  7. PJzhang:一道看线索找答案的逻辑题

    猫宁!!! 这道逻辑题,2年前就有打算解决,但是没上心,今天抽空梳理出来了思路,逻辑上可以跑的通,不至于以后慢慢忘了,这道题和数独题基本类似,但是也许更花时间,做这种题最好看着线索列图标,省的不停翻页 ...

  8. python基础之逻辑题(3)

    Python基础之逻辑题(3) 1.编写一个函数实现将IP地址转换成一个整数 2.求结果:---lambda 3.求a的结果 4.求下面nums的输出 5.求下面片段的输出 6.写出程序的结果:--- ...

  9. python基础之逻辑题(2)

    python基础之逻辑题(2) 1.若k为整数,下列while循环执行的次数为? 2.请输出正确结果-----numbers? 3.求结果-----math?   4.求结果-----sum? 5.输 ...

随机推荐

  1. 前端JS利用canvas的drawImage()对图片进行压缩

    对于大尺寸图片的上传,在前端进行压缩除了省流量外,最大的意义是极大的提高了用户体验. 这种体验包括两方面: 1.由于上传图片尺寸比较小,因此上传速度会比较快,交互会更加流畅,同时大大降低了网络异常导致 ...

  2. ElasticSearch refresh API

    在 Elasticsearch 中,写入和打开一个新段的轻量的过程叫做 refresh . 默认情况下每个分片会每秒自动刷新一次.这就是为什么我们说 Elasticsearch 是 近 实时搜索: 文 ...

  3. redhat mount iso as one yum repository

    prepare redhat DVD iso rhel-server-6.4-x86_64-dvd.iso mount cd / mkdir /mnt/rhel mount -o loop rhel- ...

  4. 配置php扩展redis

    环境说明: 系统版本    CentOS 6.9 x86_64 软件版本    nginx-1.12.2        php-5.5.38        yum安装redis3.2.11 php扩展 ...

  5. ecshop_商品描述远程图片自动本地化插件

    解压缩文件,覆盖 ecshop 的 \includes\fckeditor文件夹. 这样在后台添加商品的商品详细描述,编辑器最后一个按钮就是自动下载 远程图片到你的网站空间,这样可防止对方网站图片失效 ...

  6. 10g full join 优化

    今天一个女生咨询我报名学优化.聊着聊着就让我优化一个sql 由于怕泄密,所以删除了 sql . 不好意思 该sql是 olap 的, 在oracle10g 上面跑.跑一次要33秒钟.一般olap报表. ...

  7. 使用Kinect2作为Oculus游戏应用的输入设备

    注: 文章写于2015年8月, 眼下VR游戏Demo已经完结, 所以把上一次预研的一些经验分享出来, 希望对大家有所帮助 背景 初接触Oculus时, 从网上下载了一大堆的Demo来体验, 可是, 操 ...

  8. OpenSSL 有关密钥的那些事儿(HOWTO keys)

    <DRAFT!> OpenSSL 有关密钥的那些事儿(HOWTO keys) 1. 介绍(Introduction) Keys are the basis of public key al ...

  9. SSRF漏洞的挖掘经验

    本文转自:https://sobug.com/article/detail/11 SSRF概述 SSRF(Server-Side Request Forgery:服务器端请求伪造) 是一种由攻击者构造 ...

  10. PHP面试题及答案解析(1)—PHP语法基础

    1. strlen( )与 mb_strlen( )的作用分别是什么? strlen和mb_strlen都是用于获取字符串长度.strlen只针对单字节编码字符,也就是说它计算的是字符串的总字节数.如 ...