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. C# MQTT mqtt客户端,发布订阅消息

    如果想用C#来和mqtt的服务器进行数据交互的话,有一个常见的选择,那就是 MQTTNET 地址如下:https://github.com/chkr1011/MQTTnet 那个库在最近几个版本升级的 ...

  2. 最简单的ArcGIS Engine应用程序(上)

    名词: IWorkspaceFactory 工作空间工厂 ShapeFileWorksapceFactory 矢量文件工作空间工厂 IWorkspce 工作空间 IFeatrueWorkspace 要 ...

  3. RF中for循环

    robotframework支持FOR循环语句,语法和Python的语法基本相同,但robotframework中,“FOR”关键字前面需要增加一个“:”,写成“:FOR”,其它与Python的语法相 ...

  4. 2019关于phpstudy软件后门简单分析

    2019.9.20得知非官网的一些下载站中的phpstudy版本存在后门文件   说是官网下的就没有后门 20号出现的新闻 今天phpstudy官网21号又更新一波 不太好说这是什么操作哦 此地无银三 ...

  5. JSON:JSON对象和JSON数组混排的复杂字符串

    在java中的一个好用的JSON工具包:net.sf.json.JSONObject 和 net.sf.json.JSONArray 一 解析JSON对象和JSON数组类型混排的复杂字符串 举个例子: ...

  6. libevent::实现的低级 socket

    LibEvent 实现的低级 ROT13 例子 #include <cstdio> #include <netinet/in.h> #include <sys/socke ...

  7. JetBrains系列软件激活码

    T3ACKYHDVF-eyJsaWNlbnNlSWQiOiJUM0FDS1lIRFZGIiwibGljZW5zZWVOYW1lIjoi5bCP6bifIOeoi+W6j+WRmCIsImFzc2lnb ...

  8. 【Autofac打标签模式】PropertySource和Value

    [ Autofac打标签模式]开源DI框架扩展地址: https://github.com/yuzd/Autofac.Annotation/wiki *:first-child { margin-to ...

  9. 【Leetcode 做题学算法周刊】第一期

    首发于微信公众号<前端成长记>,写于 2019.10.28 背景 本文记录刷题过程中的整个思考过程,以供参考.主要内容涵盖: 题目分析设想 编写代码验证 查阅他人解法 思考总结 目录 1. ...

  10. LeetCode108——Convert Sorted Array to Binary Search Tree

    题目: Given an array where elements are sorted in ascending order, convert it to a height balanced BST ...