Description

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 na and b (0 ≤ a, b < n ≤ 100).

Output

Print the single number — the number of the sought positions.

Sample test(s)

input
3 1 1
output
2
input
5 2 3
output
3

题解:Petr站在一个n人的队列里,已知站在他前面的人不少于a,站在他后面的人不多于b,求Petr站位的所有可能数目。

判断n-a和b的大小关系,如果前者大,考虑b,否则,考虑n-a。

代码:

 #include <stdio.h>
#include <stdlib.h> int main()
{
int n, a, b, c, r;
scanf("%d%d%d", &n, &a, &b);
c = n-a-;
if(c > b) {
r = b+;
}else {
r = c+;
}
printf("%d", r);
return ;
}

Problem -124A - Codeforces

转载请注明出处:http://www.cnblogs.com/michaelwong/p/4116499.html

The number of positions的更多相关文章

  1. Codeforces 124A - The number of positions

    题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't ...

  2. 浙南联合训练赛 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 ...

  3. A. The number of positions

    A. The number of positions time limit per test 0.5 second memory limit per test 256 megabytes input ...

  4. (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 ...

  5. [LeetCode] Total Hamming Distance 全部汉明距离

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  6. [LeetCode] Hamming Distance 汉明距离

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  7. Total Hamming Distance

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  8. Hamming Distance

    The Hamming distance between two integers is the number of positions at which the corresponding bits ...

  9. 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 ...

随机推荐

  1. poj 3411 Paid Roads

    题意:有m条路,n座城市,走这些路是要付费的,每条路由两种付费方案,设一条路两端是a,b,如果走完这条路在b点付费的话,应付r,如果走这条路之前在c点付费的话,应付p,求从1端点走到n端点的最小费用. ...

  2. OpenGL鼠标旋转图像

    (鼠标旋转功能) #include <iostream> using namespace std; #include<gl/glut.h> GLfloat transx,tra ...

  3. 【转】unity3d的常用快捷键

    Unity3D默认的快捷键. shift +方向键             向“向方向键前进” Windows系统Unity3D中的快捷键 组合键 键 功能 File 文件 Ctrl   N New ...

  4. Stack的实现

    public class MyStack<AnyType> { private AnyType [] theItems; private final int DEFAULT_CAPACIT ...

  5. USB_OTG_study

    1 USB OTG的工作原理 OTG补充规范对USB 2.0的最重要的扩展,是其更具节能性的电源管理和允许设备以主机和外设两种形式工作.OTG有两种设备类型:两用OTG设备(Dualrole devi ...

  6. Mobile Service更新和 Notification Hub 对Android的支持

    本周,我们要推出一些更新,使移动服务成为移动应用程序更强大.更灵活的后端,同时推出一个与移动服务或网站结合使用的免费 20MB SQL 数据库,并且将支持通过Notification Hub中的 GC ...

  7. c语言结构体排序示例

    设计性实验编程实现对学生成绩表的相关信息排序.实验要求:⑴ 建立一个由n个学生的考试成绩表,每条信息由学号.姓名和分数组成.⑵ 按学号排序,并输出排序结果.⑶ 按分数排序,分数相同的则按学号有序,并输 ...

  8. DevExpress.XtraCharts.chartControl

    private Dictionary<string, double> chartPieDataDic = new Dictionary<string, double>(); p ...

  9. IT人员----怎么把电脑窗口设置成淡绿色

    大夫建议电脑屏幕不要用白色,因为白色对眼睛的刺激是最大的.像我们这样整天对着电脑,也应该注意一下.其实,只要稍微设置一下,就能让你电脑上的窗口从白花花的颜色变成淡淡的绿色. 设置方法:打开控制面板中的 ...

  10. Java面试题Tomcat的优化经验

    一.掉对web.xml的监视,把jsp提前编辑成Servlet.有富余物理内存的情况,加大tomcat使用的jvm的内存 二.服务器资源 服务器所能提供CPU.内存.硬盘的性能对处理能力有决定性影响. ...