A. The number of positions
0.5 second
256 megabytes
standard input
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.
The only line contains three integers n, a and b (0 ≤ a, b < n ≤ 100).
Print the single number — the number of the sought positions.
3 1 1
2
5 2 3
3
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.
#include<iostream>
using namespace std;
int main()
{
int n,a,b;
while(cin>>n>>a>>b)
{
int cnt=;
for(int i=;i<n;i++)
{
if(i>=a&&n-i-<=b)
cnt++;
}
cout<<cnt<<endl;
}
return ;
}
A. The number of positions的更多相关文章
- The number of positions
Description The number of positions time limit per test: 0.5 second memory limit per test: 256 megab ...
- Codeforces 124A - The number of positions
题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't ...
- 浙南联合训练赛 H - The number of positions
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say ...
- (Codeforce)The number of positions
Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say ...
- [LeetCode] Total Hamming Distance 全部汉明距离
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- [LeetCode] Hamming Distance 汉明距离
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- Total Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits ...
- 461. Hamming Distance and 477. Total Hamming Distance in Python
题目: The Hamming distance between two integers is the number of positions at which the corresponding ...
随机推荐
- Error: Cannot run program "/home/xxx/android_developer_tools/android-ndk-r8/ndk-build.cmd": Unknown reason
运行OpenCV官方例子 tutorial-2-mixedprocessing 总提示 /home/xxx/android_developer_tools/ 明明在PATH中采用好几种方法都加入了 ...
- linux 中更改权限命令chown,chmod,chgrp
写在前面,关于chown,chmod的区别 chown用法 用来更改某个目录或文件的用户名和用户组的 chown 用户名:组名 文件路径(可以是就对路径也可以是相对路径) 例1:chown root: ...
- Codeforces #505(div1+div2) B Weakened Common Divisor
题意:给你若干个数对,每个数对中可以选择一个个元素,问是否存在一种选择,使得这些数的GCD大于1? 思路:可以把每个数对的元素乘起来,然后求gcd,这样可以直接把所有元素中可能的GCD求出来,从小到大 ...
- Opencv读取图片像素值并保存为txt文件
#include <opencv2/opencv.hpp>#include<vector>#include <fstream> using namespace st ...
- CMake 默认编译、链接选项
查看cmake默认编译和链接的参数设置 CMakeLists.txt 文件内容: cmake_minimum_required(VERSION 3.2) message(STATUS "CM ...
- CF702E Analysis of Pathes in Functional Graph
倍增练习题. 基环树上倍增一下维护维护最小值和权值和,注意循环的时候$j$这维作为状态要放在外层循环,平时在树上做的时候一个一个结点处理并不会错,因为之前访问的结点已经全部处理过了. 时间复杂度$O( ...
- JAVA隐藏鼠标的方法
JAVA隐藏鼠标的方法 2012年06月03日 19:13:21 阅读数:2436 JAVA隐藏鼠标光标,可以有2种方法. 都是通过如下语句重新设置光标 Toolkit.getDefaultToolk ...
- Mysql--基本配置
登录的常用参数 mysql -uroot -p 之后再加上密码 mysql -uroot -p+密码 这个方法不安全 mysql -hlocalhost -uroot -p 之后再加上密码 ...
- 非阻塞socket与epoll
阻塞socket. –阻塞调用是指调用结果返回之前,当前线程会被挂起.函数只有在得到结果之后才会返回. –对于文件操作read,fread函数调用会将线程阻塞. –对于socket,accept与re ...
- APP 市场需求网址
http://mi.talkingdata.com/terminals.html?terminalType=4