题目链接:

space=1&num=1725" target="_blank">http://acm.timus.ru/problem.aspx?space=1&num=1725

Every fall, all movies are shown to a full house at one of the most popular cinema theatres in Yekaterinburg because students like to spend their time sitting in a cosy chair and watching a movie instead
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.
Student of the Department of Philosophy Vasya is an enthusiastic movie-goer and an equally enthusiastic hater of mathematics. He was the first to buy a ticket to the first exhibition of a new movie.
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

The only input line contains the total number of seats n in the row where Vasya is sitting and the number of his seat k (1 ≤ k ≤ n ≤ 50; n is even). These
integers are separated with a space. The seats in the row are numbered starting with one.

Output

Output the maximal number of people who would stumble over Vasya's feet.

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!(数学啊 )的更多相关文章

  1. URAL 1161 Stripies(数学+贪心)

    Our chemical biologists have invented a new very useful form of life called stripies (in fact, they ...

  2. URAL 2047 Maths (数学)

    对于一个数来说,它的除数是确定的,那么它的前驱也是确定的,而起点只能是1或2,所以只要类似筛法先预处理出每个数的除数个数 ,然后递推出每个数往前的延伸的链长,更新最大长度,记录对应数字.找到maxn以 ...

  3. URAL 1731. Dill(数学啊 )

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1731 1731. Dill Time limit: 0.5 second Memory ...

  4. URAL 1826. Minefield(数学 递归)

    题目链接:http://acm.timus.ru/problem.aspx? space=1&num=1826 1826. Minefield Time limit: 0.5 second M ...

  5. 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 ...

  6. URAL 1820. Ural Steaks(数学啊 )

    题目链接:space=1&num=1820" target="_blank">http://acm.timus.ru/problem.aspx? space ...

  7. ural 2029 Towers of Hanoi Strike Back (数学找规律)

    ural 2029 Towers of Hanoi Strike Back 链接:http://acm.timus.ru/problem.aspx?space=1&num=2029 题意:汉诺 ...

  8. ural 2032 Conspiracy Theory and Rebranding (数学水题)

    ural 2032  Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...

  9. 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 ...

随机推荐

  1. UpdataData

    MFC中有一个UpdataData函数,有二个参数:TRUE和FLASE,二个参数什么时候用, 开始的时候我也迷糊,后来才发现: UpdataData(TRUE):是把控件上的值刷新到变量中: Upd ...

  2. 主流JavaScript框架(Dojo、Google Closure、jQuery、Prototype、Mootools和YUI)的分析和对比

    本文主要选取了目前比较流行的JavaScript框架Dojo.Google Closure.jQuery.Prototype.Mootools和YUI进行对比,主要是根据网上的资料整理而成,希望可以供 ...

  3. Oracle控制文件操作

    控制文件是连接instance和 database的纽带.记录了database的结构信息. 控制文件是1个2进制文件.记录的是当前database的状态. 控制文件可以有多个,在参数文件中通过con ...

  4. 降低成本是永恒的追求(xamarin)

    减少为主线的成本始终是一个社会经济发展.经济活动似乎很.商业模式的出现相关.我记得早起写Web程序,真正的企业并不多忙.大部分时间处理与浏览器的问题之间的差异所带来. 有些型号也做了屏蔽这样的差别,有 ...

  5. 鼠标右键怎么清除Catalyst Control Center

    开始→运行→regedit→找到HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\ACE→双击并修改其键值 可以删除 ...

  6. Tomcat在Linux上安装

    1. 下载并 安装 tomcat wget  http://mirror.bit.edu.cn/apache/tomcat/tomcat-8/v8.0.14/bin/apache-tomcat-8.0 ...

  7. linux内核笔记-内核同步

    linux内核就相当于不断对请求进行响应的服务器,这些请求可能来自CPU,可能来自发出中断的外部设备.我们将内核看作两种请求的侍者. (1)老板提出请求,侍者如果空闲,为老板服务.(系统调用或异常) ...

  8. ubuntu12 下怎样上网

    1,host 就是WIN7 使用WIFI上网 2.打开设置你的VM 8 edit--Virutal network editor--VMnet0--Bridged (connect VMs to di ...

  9. 2014年辛星解读Javascript之用DOM动态操纵HTML元�

    关于DOM,我们了解了能够用DOM操纵HTML的一些属性和样式,还能够为HTML元素绑定事件等等,那么接下来,我们将涉及到用DOM来动态的创建.删除HTML等一些操作,我的核心思路还是重实战,因此,代 ...

  10. Learning Cocos2d-x for WP8(3)——文字篇

    原文:Learning Cocos2d-x for WP8(3)--文字篇 C#兄弟篇Learning Cocos2d-x for XNA(3)——文字篇 文字,是人类文明的象征. 文字显示,可用字符 ...