URAL 1725. Sold Out!(数学啊 )
题目链接: space=1&num=1725" target="_blank">http://acm.timus.ru/problem.aspx?space=1&num=1725
of attending lectures and seminars. Unfortunately, the distance between the rows of seats in the cinema hall is small, and people constantly stumble over other people's feet as they get to their seats before the film exhibition. Entering the hall, a visitor
chooses from which end of the row (left or right) he will make his way to his seat. He chooses it in such a way that the number of people over whose feet he will stumble will be minimal. If these numbers are equal for the left and right ends, the visitor chooses
the end of the row which is closer to his seat.
When Vasya entered the hall and sat down in his seat, he saw that other seats in the row were still unoccupied. Vasya knew that by the time the exhibition started the hall would be full. Therefore, quite a number of other visitors would stumble over his feet
while getting to their seats. Despite his hatred for mathematics, Vasya was able to instantly estimate the maximal number of people that would stumble over his feet before the exhibition. Can you do the same?
Input
integers are separated with a space. The seats in the row are numbered starting with one.
Output
Sample
| input | output |
|---|---|
4 1 |
1 |
代码例如以下:
#include <cstdio>
int main()
{
int n, k;
while(~scanf("%d%d",&n,&k))
{
int ans;
if(n == 2)//两边
{
ans = 0;
}
else if(k <= n/2)
{
ans = n-2-k;
}
else
{
ans = k-3;
}
printf("%d\n",ans);
}
return 0;
}
URAL 1725. Sold Out!(数学啊 )的更多相关文章
- URAL 1161 Stripies(数学+贪心)
Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...
- URAL 2047 Maths (数学)
对于一个数来说,它的除数是确定的,那么它的前驱也是确定的,而起点只能是1或2,所以只要类似筛法先预处理出每个数的除数个数 ,然后递推出每个数往前的延伸的链长,更新最大长度,记录对应数字.找到maxn以 ...
- URAL 1731. Dill(数学啊 )
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731 1731. Dill Time limit: 0.5 second Memory ...
- URAL 1826. Minefield(数学 递归)
题目链接:http://acm.timus.ru/problem.aspx? space=1&num=1826 1826. Minefield Time limit: 0.5 second M ...
- URAL 1876 Centipede's Morning(数学)
A centipede has 40 left feet and 40 right feet. It keeps a left slippers and b right slippers under ...
- URAL 1820. Ural Steaks(数学啊 )
题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...
- ural 2029 Towers of Hanoi Strike Back (数学找规律)
ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...
- ural 2032 Conspiracy Theory and Rebranding (数学水题)
ural 2032 Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...
- URAL 2067 Friends and Berries (推理,数学)
题意:给定 n 个人,每个人两个值s, r,要满足,p(v, u) = sqrt((sv − su)^2 + (rv − ru)^2), p(v,u,w) = (p(v,u) + p(v,w) + p ...
随机推荐
- 开启程序的Visual Styles
首先看看MS对Visual Styles的解释: Windows XP and later operating systems support a feature called visual styl ...
- AdaBoost中利用Haar特征进行人脸识别算法分析与总结1——Haar特征与积分图
原地址:http://blog.csdn.net/watkinsong/article/details/7631241 目前因为做人脸识别的一个小项目,用到了AdaBoost的人脸识别算法,因为在网上 ...
- java thread reuse(good)
I have always read that creating threads is expensive. I also know that you cannot rerun a thread. I ...
- OCA读书笔记(12) - 数据库维护
查询优化器统计信息 搜集统计信息: 不是实时的: SQL> conn /as sysdbaConnected.SQL> grant select on dba_objects to sco ...
- Load and Unload
一.前言 在前一段时间,我遭遇了一个现象诡异的Bug,最后原因归结为在DllMain里错误地调用了FreeLibrary(在本文最后对此Bug有详细的解释). MSDN里关于禁止在DllMain里调用 ...
- 关于智普 - 千人免费学|Python培训|国内最权威python培训|html5
关于智普 - 千人免费学|Python培训|国内最权威python培训|html5 智普教育隶属于北京顶嵌开源科技有限公司,成立于2008年. 智普开源是基于Linux系统的互联网开源学习平台,讲求务 ...
- PHP操作Mysql中间BLOB场
1.MySQL在BLOB字段类型 BLOB场的类型用于存储二进制数据. MySQL在.BLOB它是一种类型的一系列.含有:TinyBlob.Blob.MediumBlob.LongBlob.大小上不同 ...
- String、StringBuffer与StringBuilder差分
的位置不言而喻.那么他们究竟有什么优缺点,究竟什么时候该用谁呢?以下我们从以下几点说明一下 1.三者在运行速度方面的比較:StringBuilder > StringBuffer > ...
- Ajaxterm-0.10-8.el5.noarch.rpm CentOS 5 (RHEL 5) Download
Ajaxterm-0.10-8.el5.noarch.rpm CentOS 5 (RHEL 5) Download Install Howto Download the latest epel-rel ...
- SUSE Linux 报错:too many open files in system
现网执行的oracle数据库,有一天突然报错(alert日志):too many open files in system,须要对操作系统同意句柄数进行扩充,查阅了非常多资料,改动点主要集中在例 ...