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 ...
随机推荐
- Linux下一个简单的日志系统的设计及其C代码实现
1.概述 在大型软件系统中,为了监测软件运行状况及排查软件故障,一般都会要求软件程序在运行的过程中产生日志文件.在日志文件中存放程序流程中的一些重要信息, 包括:变量名称及其值.消息结构定义.函数返回 ...
- IOS-UITextField-邮箱后缀联想赛
最近做的项目,有一个函数,百度了一下 结果没 要研究了一下. 当用户输入邮箱形式的账号时,输入完"@"符号后.联想出经常使用的邮箱 点击某一行,将改行代表邮箱自己主动输入到账号输入 ...
- wkhtmtopdf--高分辨率转HTML成PDF--目录篇
原文:wkhtmtopdf--高分辨率转HTML成PDF--目录篇 wkhtmtopdf--高分辨率转HTML成PDF(一):简述wkhtmtopdf的简介和安装 wkhtmtopdf--高分辨率转H ...
- OCP读书笔记(11) - 使用闪回技术II
闪回归档 1. 什么是闪回数据归档? 闪回归档是用来保存一个或多个表的历史数据的新数据库对象,以及该数据的存储保留和清除策略.归档只是保存数据库中一个或多个表的所有事务处理的变化的一个或多个表空间,数 ...
- 浅谈spring——spring MVC(十一)
springMVC框架主要是围绕DispatcherServlet这个核心展开,它负责拦截请求并将其分派给相应的的处理器处理,然后将结果响应给用户.包括注解驱动控制器.请求及响应信息处理.视图解析.本 ...
- ASA虚墙配置
asa配置ASA Version 8.0(2) <system>!hostname ASA5520enable password 2KFQnbNIdI.2KYOU encryptedno ...
- Wix打包系列(四) 自定义UI
原文:Wix打包系列(四) 自定义UI 除了标准的安装界面,如果我们要在安装时需要提供一些额外的信息时,这时就需要自定义界面来显示和录入这些信息. 4.1 自定义对话框 如上一章中我们测试数据库的连 ...
- BASH Shell 简易进度条小函数
不多说,直接上脚本. # processbar <current> <total> processbar() { local current=$1; local total=$ ...
- Cocos2d-x v3.0正式版尝鲜体验【3】 Label文本标签
Cocos2d-x在新版本号中增加了新的Label API.和以往不同的是,2.x的版本号是通过三个不同的类来创建不同的文本标签,而如今是模仿着精灵的创建方式.一个类创建不同形式的文本,只是核心内容还 ...
- poj1155(树形dp)
题目链接:http://poj.org/problem?id=1155 题意:电视台要直播一场比赛,电视网络刚好形成了一棵树,其中有M个为客户端,其他的为中转站,其中中转站与中转站以及中转站与客户端之 ...