题目链接:

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. RegisterHotKey注册热键,然后响应WM_HOTKEY消息

    MSDN中的一个示例代码,步骤就是RegisterHotKey注册热键,然后响应WM_HOTKEY消息 @1:这个是系统热键 #include "stdafx.h" int _cd ...

  2. 玩转Windows服务系列——命令行管理Windows服务

    原文:玩转Windows服务系列——命令行管理Windows服务 说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令, ...

  3. hdu 4963(中途相遇法)

    题目链接:Dividing a String 题意:给定一个2*n(n<=20)的字符串及每个位置的字符包含的权重,求将该字符串分成两个子序列S1.T1,要求S1=T1且abs(weight1- ...

  4. Java 建立mysql数据库连接的语句

    每次在面试时被问到jdbc的数据路链接过程都卡着,这次不怕了,背会了... 第一个,比较粗糙的 try{   Class.forName("com.mysql.jdbc.Driver&quo ...

  5. 遍历指定包名下所有的类(支持jar)(转)

    支持包名下的子包名遍历,并使用Annotation(内注)来过滤一些不必要的内部类,提高命中精度. 通过Thread.currentThread().getContextClassLoader()获取 ...

  6. form表单中的 action=./?> 是什么意思

    ./代表当前目录,?代表查询字符串为空 action="" //一般可以为空的,这里的双引号都要有的,表示提单提交给自己(也就是当前页处理)action="a.php&q ...

  7. ftk学习记(waitbox篇)

    [声明:版权全部.欢迎转载,请勿用于商业用途.  联系信箱:feixiaoxing @163.com] 前面说到了脚本.那么就看看ftk中demo与script搭配的效果是什么样的? 上面的效果图就相 ...

  8. Cocos2d-x精华教程汇总(第三期) cocos2d-x最新离线API文档下载(最新版3.6更新。。。)

    其实使用doxygen在Cocos2d-x引擎的doc目录下可以生成离线文档,但是可能每个人为了生成一个离线文档去安装甚至编译doxygen毕竟麻烦,而且现有的doxygen无法生成多语言版本的离线文 ...

  9. 【译】ASP.NET MVC 5 教程 - 4:添加模型

    原文:[译]ASP.NET MVC 5 教程 - 4:添加模型 在本节中,我们将添加一些管理电影数据库的类,这些类在ASP.NET MVC 应用程序中扮演“Model”的角色. 我们将使用.NET F ...

  10. AOP 之 6.1 AOP基础 ——跟我学spring3(转)

    http://jinnianshilongnian.iteye.com/blog/1418596