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 n, a 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. 如何更快理解和运用服务编排?(使用Goku API Gateway实现)

    上一篇博客 未来实现API管理系统的几个关键词 发布后,有不少读者私信我,让我写一篇实际运用的文章,我周末趁着有空写了这篇有关“服务编排”的文章.用的是Goku API Gateway进行演示, 希望 ...

  2. django安装以及配置

    一.django的安装和启动 1.安装 pip3 install django==1.11.22 目前来讲1.11.22版本比较稳定 2.django的创建 命令行:cmd先去到django创建目录, ...

  3. 什么是STM32的ISP?

    上一篇笔记分享了STM32的串口IAP实例:STM32串口IAP分享.其中,下载IAP程序时用ISP的方式进行下载.这里的ISP又是什么呢? ISP方式下载程序原理 ISP:In System Pro ...

  4. Node.js新手必须知道的4个JavaScript概念

    如果只需要知道一种编程语言就可以构建一个全栈的应用程序,是不是特别了不起?Ryan Dahl为了把这个想法成为现实,创造了node.js.Node.js是建立在Chrome强劲的V8 JavaScri ...

  5. luogu P3878 [TJOI2010]分金币

    [返回模拟退火略解] 题目描述 今有 nnn 个数 {ai}\{a_i\}{ai​},把它们分成两堆{X},{Y}\{X\},\{Y\}{X},{Y},求一种分配使得∣∑i∈Xai−∑i∈Yai∣|\ ...

  6. NServiceBus+RabbitMQ开发分布式应用

    前言      NServiceBus提供了8种传输管道组件,分别是Learning.MSMQ.Azure Service Bus.Azure Service Bus (Legacy).Azure S ...

  7. MS12-042 用户态调度机制特权提升漏洞

    漏洞编号:MS12-042 披露日期: 2012/6/12 受影响的操作系统:Windows 2000;XP;Server 2003;windows 7;Server 2008; 测试系统:windo ...

  8. python模块-time、datetime

    简单示例: 常用函数封装: # -*- coding: utf-8 -*- # @Time : 2019/8/6 14:37 # @Author : wangmengmeng import datet ...

  9. 5. Sersync实时同步

    rsync+Sersync数据的实时同步 sersync介绍 1.什么是实时同步 监控一个目录的变化, 当该目录触发事件(创建\删除\修改) 就执行动作, 这个动作可以是 rsync同步 ,也可以是其 ...

  10. 基于SkyWalking的分布式跟踪系统 - 环境搭建

    前面的几篇文章我们聊了基于Metrics的监控Prometheus,利用Prometheus和Grafana可以全方位监控你的服务器及应用的性能指标,在出现异常时利用Alertmanager告警及时通 ...