Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy.

Input

The only line contains three integers na and b (0≤a,b<n≤100).

Output

Print the single number − the number of the sought positions.

Examples
Input
3 1 1
Output
2
Input
5 2 3
Output
3
Note

The possible positions in the first sample are: 2 and 3 (if we number the positions starting with 1).

In the second sample they are 3, 4 and 5.

简单翻译就是排队,三个输入,一个是队伍的人数n,一个是在排在他前面不能少于a的人,另一个是排在他后面不多于b的人

输出: 他可以站的位置。

可以看第一个case input 3 1 1     他可以站2  他前面有1个人后面1个人  他可以站3 前面2个人后面没有人

idea :

1.当a>=n,则肯定没有位置供选择 则输出0

2.当a+b==n时,我们可以发现我们所能选的就是从a开始到n结束  即b个位置

3.当a+b<n时,我们可以从n-b开始到n  考虑端点就是b+1个嘛

4.当a+b>n时 且a<n,我们可以从a+1开始取,取到n,就是n-a个位置

AC:

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  if(a+b==n)
  {
    cout << b;
  }
  else if(a+b<n)
  {
    cout << b+;
  }
     else if(a>=n)
  {
    cout << ;
  }
  else
  {
    cout << n-a;
  } }

(Codeforce)The number of positions的更多相关文章

  1. (转载)Flash Number 数据类型

    (转载)http://www.g168.net/txt/flash/learningactionscript/00001183.html Number 数据类型 Number 数据类型是双精度浮点数. ...

  2. java基础系列(一):Number,Character和String类及操作

    这篇文章总结了Java中最基础的类以及常用的方法,主要有:Number,Character,String. 1.Number类 在实际开发的过程中,常常会用到需要使用对象而不是内置的数据类型的情形.所 ...

  3. LeetCode之旅(18)-Happy Number

    题目 Write an algorithm to determine if a number is "happy". A happy number is a number defi ...

  4. LeetCode(137) Single Number II

    题目 Given an array of integers, every element appears three times except for one. Find that single on ...

  5. LeetCode(202) Happy Number

    题目 Write an algorithm to determine if a number is "happy". A happy number is a number defi ...

  6. LeetCode之旅(17)-Ugly Number

    题目: Write a program to check whether a given number is an ugly number. Ugly numbers are positive num ...

  7. LeetCode(306) Additive Number

    题目 Additive number is a string whose digits can form additive sequence. A valid additive sequence sh ...

  8. LeetCode(65) Valid Number

    题目 Validate if a given string is numeric. Some examples: "0" => true " 0.1 " ...

  9. (Codeforce)Correct Solution?

    One cold winter evening Alice and her older brother Bob was sitting at home near the fireplace and g ...

随机推荐

  1. HelloWin详解

    (注意:遇到程序在弄懂之后一定要自己去敲,一定要自己去敲,一定要自己去敲) (注意:遇到程序在弄懂之后一定要自己去敲,一定要自己去敲,一定要自己去敲) (注意:遇到程序在弄懂之后一定要自己去敲,一定要 ...

  2. 代码审计-四叶草杯线下awd比赛源码web2

    今晚简单来看看那天比赛的源码吧,比赛的时候还是有些慌没有好好去静下心看代码. awd给的题中的漏洞,都是那种可以快速让你利用拿到权限后得到flag的那种,特别复杂利用的一般没有. 建议先黑盒去尝试,例 ...

  3. 运用第一性原理探寻AI本质

    摘要:使用第一性原理探讨理解AI本质. 文章来源:宜信技术学院|宜信支付结算团队技术分享第二期-支付结算机器学习技术团队负责人 刘创 分享<AI与第一性原理> 分享者:宜信支付结算机器学习 ...

  4. mysql 二十余种报错注入姿势

    1.floor()  floor 和group by 搭配使用 利用group by 的key唯一性 和mysql 编码执行顺序导致二次执行产生不同key ))) ) 数值型注入时 不用闭合‘  进行 ...

  5. RIDE-工程、测试套件、测试用例三者关系

    理论 type的选择: 一般来说:测试项目(directory)-测试套件(file)-测试用例 本质上,“测试项目”和“测试套件”并没有什么区别,但是testcase只能放在file类型的test ...

  6. 6. SSH远程管理服务实战

    1. SSH基本概念? ssh是一个应用层安全协议 2.SSH主要的功能是? 实现远程登录, 数据传输过程中进行加密. 钉钉(澡堂模式) 远程登录: ssh telnet 3.SSH与Telnet之间 ...

  7. 玩转 RTC时钟库 DS3231

    1.前言     接着博主的上一篇 玩转 RTC时钟库 + DS1302,这一篇我们重点讲解DS3231时钟模块.没有看过上一篇的同学,麻烦先去阅读一下,因为很多理论基础已经在上一篇做了详细讲解,这里 ...

  8. 百万年薪python之路 -- 变量及if的练习

    1.简述变量命名规范 1.变量由数字,字母,下划线组成 2.不能以数字开头 3.不能使用python关键字 4.不能使用中文和拼音命名 5.区分大小写 6.变量名要具有描述性 7.推荐写法 7.1驼峰 ...

  9. Beetlex服务框架之Webapi版本访问控制

    在应用服务中API更新是很普遍的事情,为了服务良好地运作很多时候需要新旧版本同时兼容:为了应对这一系列的需求FastHttpApi在新版中强化了Url重写机制来支持API访问版本控制,由原来固定的重写 ...

  10. 计算机网络(2)-- URL、HTTP、HTTPS、HTML

    1.万维网WWW 万维网WWW(World Wide Web)是一个大规模的.联机式的信息储藏所,英文简称Web. 万维网用链接的方法能非常方便地从互联网上的一个站点访问另一个站点,从而主动地按需获取 ...