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 ...
随机推荐
- python的文件锁使用
python的文件锁目前使用的是fcntl这个库,它实际上为 Unix上的ioctl,flock和fcntl 函数提供了一个接口. 1.fcntl库的简单使用 import fcntl import ...
- latex 小模板
\documentclass[11pt,a4paper,english]{article}\usepackage[T1]{fontenc}\usepackage[utf8]{inputenc}\use ...
- C# 把一个文件夹下所有文件删除
public static void DelectDir(string srcPath){ try { DirectoryInfo dir = new DirectoryInfo(srcPath); ...
- .NET回归 HTML----超文本标记语言(暂时无图)
HTML用来做网页,文件拓展名改为html可以形成网页 超文本标记语言==超越了文字的范畴,除了文字还可以有图片.视频.音频.动画特效等其它内容,由标记符号<>组成的一门计算机编程语言 H ...
- Linux minicom命令
一.简介 minicom是Linux下的超级终端,与Windows下的超级终端功能相似,可以通过串口控制外部的硬件设备,可以用于管理和控制嵌入式设备 二.安装 1)yum安装 yum install ...
- linux环境安装python
linux环境下安装python3,一步一步来吧! 安装python3 安装readline-devel依赖 ,用于解决python3安装完成后,退格和方向键乱码问题 yum install read ...
- 牛客网java基础题分类
http://www.cnblogs.com/tptptptp/p/5904075.html
- [译]Javascript中的循环
本文翻译youtube上的up主kudvenkat的javascript tutorial播放单 源地址在此: https://www.youtube.com/watch?v=PMsVM7rjupU& ...
- python:格式化输出整数
import math #default print "PI = %f" % math.pi #width = 10,precise = 3,align = left print ...
- Dojo Style Guide
Contents: General Quick Reference Naming Conventions Specific Naming Conventions Files Variables Lay ...