Helvetic Coding Contest 2016 online mirror A1
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:
- survive the event (they experienced death already once and know it is no fun),
- 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?
The only line of input contains one integer: N, the number of attendees (1 ≤ N ≤ 109).
Output one integer: the smallest number of brains in the chest which allows Heidi to take one brain home.
1
1
4
2
海盗分金问题,不懂的可以先看看,然后这题目都知道做了
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
//#include<map>
#include<sstream>
#include<set>
#include<queue>
#include<vector>
#include<algorithm>
#include<limits.h>
#define inf 0x3fffffff
using namespace std;
const double pi = acos(-1.);
int main()
{
int n;
cin>>n;
if(n==1)
{
puts("1");
}
else
{
int mid=n/2;
cout<<n-mid<<endl;
}
return 0;
}
Helvetic Coding Contest 2016 online mirror A1的更多相关文章
- CF 690C3. Brain Network (hard) from Helvetic Coding Contest 2016 online mirror (teams, unrated)
题目描述 Brain Network (hard) 这个问题就是给出一个不断加边的树,保证每一次加边之后都只有一个连通块(每一次连的点都是之前出现过的),问每一次加边之后树的直径. 算法 每一次增加一 ...
- Helvetic Coding Contest 2016 online mirror F1
Description Heidi has finally found the mythical Tree of Life – a legendary combinatorial structure ...
- Helvetic Coding Contest 2016 online mirror B1
Description The zombies are gathering in their secret lair! Heidi will strike hard to destroy them o ...
- Helvetic Coding Contest 2016 online mirror C2
Description Further research on zombie thought processes yielded interesting results. As we know fro ...
- Helvetic Coding Contest 2016 online mirror D1
Description "The zombies are lurking outside. Waiting. Moaning. And when they come..." &qu ...
- Helvetic Coding Contest 2016 online mirror C1
Description One particularly well-known fact about zombies is that they move and think terribly slow ...
- Helvetic Coding Contest 2019 online mirror (teams allowed, unrated)
http://codeforces.com/contest/1184 A1 找一对整数,使x^x+2xy+x+1=r 变换成一个分式,保证整除 #include<iostream> #in ...
- Helvetic Coding Contest 2017 online mirror (teams allowed, unrated)
G. Fake News (easy) time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Helvetic Coding Contest 2017 online mirror (teams allowed, unrated) M
Description The marmots have prepared a very easy problem for this year's HC2 – this one. It involve ...
随机推荐
- 我的第一个Socket程序-SuperSocket使用入门(二)
操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操操 辛辛苦苦写那么久的博客,最后手贱点了全屏富文本编辑器 ...
- 如何在Eclipse下查看JDK源代码以及java源代码阅读方法(转载)
不会看JDK源代码,相当于没学过Java. 网上不容易找到一篇帮助我解决了如何在Eclipse下查看JDK源代码 的文章. 核心提示:在Eclipse中查看JDK类库的源代码!!! 设置: 1.点 w ...
- JavaScript中数值和对象
一.创建对象并将其初始化 a.使用new创建对象和方法 <<!DOCTYPE html> <html> <head> <mete http-equiv ...
- re.match
- day17 10.jdbc的crud操作
每次都是注册驱动,获取连接,然后执行.每次都写很累,肯定能抽取出来一些东西.Java里面是这样的,相同的东西可以抽取做成一个方法.用的时候调这方法就OK了.这方法抽取到什么程度呢? package c ...
- css知多少(5)——选择器(转)
css知多少(5)——选择器 1. 引言 从本节开始,就进入本系列的第二个部分——css和html的结合——说白了就是选择器. CSS中定义了样式,如何将这些样式设置到相应的html节点上?就不得 ...
- 利用JavaScriptCore实现以下简单的功能(平方和)
#import "RootViewController.h" #import <JavaScriptCore/JavaScriptCore.h> @interface ...
- 把文档转化为PDF再用PS处理PDF
最近工作中遇到类似下面这样的一个文档. 文档当前设置的是A4 横版打印,可以明显的看到打印的分界线,这样直接打印出来,是没有下面那行“bbbbbbbbbbbbbbbbbb”的,怎么办?可以通过 页面布 ...
- 炫酷实用的CSS3代码垂直手风琴菜单
今天在微博上看到别人分享的代码,自己拿来自己保存着. 代码效果如下: 下面是源码: index.html <!DOCTYPE html> <html > <head> ...
- [转]MYSQL5.7版本sql_mode=only_full_group_by问题
转至:https://www.cnblogs.com/zhi-leaf/p/5998820.html 具体出错提示: [Err] 1055 - Expression #1 of ORDER BY cl ...