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. Spring Cloud Gateway的动态路由怎样做?集成Nacos实现很简单

    一.说明 网关的核心概念就是路由配置和路由规则,而作为所有请求流量的入口,在实际生产环境中为了保证高可靠和高可用,是尽量要避免重启的,所以实现动态路由是非常有必要的:本文主要介绍 Spring Clo ...

  2. Kubernetes网络插件Flannel的三种工作模式

    跨主机通信的一个解决方案是Flannel,由CoreOS推出,支持3种实现:UDP.VXLAN.host-gw 一.UDP模式(性能差) 核心就是通过TUN设备flannel0实现(TUN设备是工作在 ...

  3. PHP range

    1.函数的作用:生成范围内的数据 2.函数的参数: @param mixed $start @param mixed $end @param mixed $step 3.例子: <?php $n ...

  4. go-json类

    package main import ( "encoding/json" "fmt" ) /* { "company":"itc ...

  5. if-elif-else分支判断语句(附加continue和break)---举例说明

    一.分支循环语句: a=input("请输入一个五位数字") if(len(a)!=5): print("输入的数字不合格"); elif(a[0::]==a[ ...

  6. 小白学 Python(7):基础流程控制(上)

    人生苦短,我选Python 前文传送门 小白学 Python(1):开篇 小白学 Python(2):基础数据类型(上) 小白学 Python(3):基础数据类型(下) 小白学 Python(4):变 ...

  7. spring security原理-学习笔记2-核心组件

    核心组件 AuthenticationManager,ProviderManager和AuthenticationProvider AuthenticationManager只是一个接口,实际中是如何 ...

  8. MyBatis 示例-缓存

    MyBatis 提供两种类型的缓存,一种是一级缓存,另一种是二级缓存,本章通过例子的形式描述 MyBatis 缓存的使用. 测试类:com.yjw.demo.CacheTest 一级缓存 MyBati ...

  9. 百万年薪python之路 -- 模块二

    1. 序列化模块 什么是序列化呢? 序列化的本质就是将一种数据结构(如字典.列表)等转换成一个特殊的序列(字符串或者bytes)的过程就叫做序列化. 为什么要有序列化模块? 如果你写入文件中的字符串是 ...

  10. Ubuntu18.04 安装谷歌BBR

    说明:Ubuntu 18.04前几天发布了,改变挺大的,内核也直接升到了正式版4.15,而BBR内核要求为4.9,也就是说满足了,所以我们不需要换内核就可以很快的开启BBR,这里简单说下方法. 提示: ...