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;
  } }

最新文章

  1. Python开发入门与实战18-Windows Azure 虚拟机部署
  2. 移动终端学习2:触屏原生js事件及重力感应
  3. 【jsp+jpa】Check your ViewResolver setup!
  4. 在 windows 上面安装 tensorflow
  5. NET Core 整合Autofac和Castle
  6. .net web 开发平台- 表单设计器 一(web版)
  7. 关机和重启Linux命令
  8. cesium自定义气泡窗口infoWindow后续优化篇
  9. MATLAB中绘制图形的时候,坐标和标题倒置
  10. 在VS 2017 下创建 Xamarin NuGet Package
  11. 点火开关分为4个档位,分别是off,acc,IG-on,和ST
  12. 导入另一个 Git库到现有的Git库并保留提交记录
  13. XX-net
  14. Azure 中 Windows 虚拟机的大小
  15. Nginx反向代理下IIS获取真实IP
  16. win10 uwp unix timestamp 时间戳 转 DateTime
  17. [并查集] 1107. Social Clusters (30)
  18. LeetCode-330.Patching Array
  19. 【总结】2017年当下最值得你关注的前端开发框架,不知道你就OUT了!
  20. ORB-SLAM(十二)优化

热门文章

  1. 快速入门Maven(一)
  2. 机器学习:IB1算法的weka源码详细解析(1NN)
  3. luoguP1006 传纸条
  4. [JZOJ4685] 【NOIP2016提高A组8.12】礼物
  5. java学习3-流程控制与数组
  6. Arduino学习笔记① 初识Arduino
  7. 百万年薪python之路 -- 请求跨域和CORS协议详解
  8. (day27)subprocess模块+粘包问题+struct模块+ UDP协议+socketserver
  9. Android应用程序版本升级时签名冲突
  10. fenby C语言 P9