A. The number of positions
time limit per test
0.5 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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
Copy
3 1 1
output
Copy
2
input
Copy
5 2 3
output
Copy
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个人,求这个人可以在位置的总个数
分析:
长度总体为n
其实可以站的位置就是n-a的范围和b的范围的交集min(n-a,b+1)
b+1的原因:假设b=2,则有三个位置n,n-1,n-2均能保证后面最多有两个人
#include<cstdio>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<functional>
#include<cstring>
#include<string>
#include<cstdlib>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
using namespace std;
#define N 100000+5
#define rep(i,n) for(int i=0;i<n;i++)
#define sd(n) scanf("%d",&n)
#define sll(n) scanf("%lld",&n)
#define pd(n) scanf("%d\n",n)
#define pll(n) scanf("%lld\n",n)
#define MAX 26
typedef long long ll;
const ll mod=1e6;
ll a[N];
bool vis[N];
char c[]={'6','7','8','9','T','J','Q','K','A'};
int main(){
int n,x,y;
scanf("%d%d%d",&n,&x,&y);
cout<<min(n-x,y+1);
return 0;
}