• Collective Mindsets (easy)(逻辑题)


    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是等级最高的,他自己想带走一个大脑,问最少需要多少大脑。
    //海盗分金问题,看似简单,但是,细思恐极。。。找的是规律,这题还简单,下题才难想
     1 #include <stdio.h>
     2 int main()
     3 {
     4     int n;
     5     while (scanf("%d",&n)!=EOF)
     6     {
     7         if (n%2==0)
     8         printf("%d
    ",n/2);
     9         else
    10         printf("%d
    ",n/2+1);
    11     }
    12     return 0;
    13 }
    View Code
  • 相关阅读:
    sersync+rsync原理及部署
    rsync同步
    zabbix 3.2.2 agent端(源码包)安装部署
    zabbix配置
    Netbackup media server部署报错
    Oracle_rac命令
    Linux系统克隆为iso镜像盘(类似win gost)
    Nebackup清除磁带数据重新使用
    V7000初始化
    【数据案例】服务器崩溃后的数据恢复方法
  • 原文地址:https://www.cnblogs.com/haoabcd2010/p/5924894.html
Copyright © 2020-2023  润新知