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. 02Android用户界面优化之(一)Android Fragment

    一.使用Fragment 1.AndroidManifest.xml文件 <?xml version="1.0" encoding="utf-8"?> ...

  2. Asp.net MVC + EF6.0 经常出现的问题

    1.运行视图时出现问题:未能加载文件或程序集"EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c ...

  3. JavaScript Dispatch Event

    <html> <head> <script type="text/javascript"> function performClick(elem ...

  4. Spring-----1、Spring简介和Spring3.0的变化

    转载自:http://blog.csdn.net/hekewangzi/article/details/41324441

  5. Linux命令--链接文件的那些事

    linux 链接ln的使用 linux操作系统下ln的使用方式: ln [option] source_file dest_file #source_file是待建立链接文件的文件,dest_file ...

  6. mysql优化(1) 观察服务器周期性变化

    先把nginx和memcached环境开启 /usr/local/nginx/sbin/nginx /usr/local/fastphp/sbin/php-fpm /usr/local/memcach ...

  7. codeforces 702E Analysis of Pathes in Functional Graph 倍增

    题目链接 给一个图, 然后给出每条边的权值和一个k值. 让你求出从每个点出发, 走k次能获得的边权的和以及边权的最小值. 用倍增的思想, 求出每个点走一次能到达的点, 权值和以及最小值, 走两次..四 ...

  8. 指定端口号,多线程扫描局域网内IP地址

    小白第一次发博客,请各路大神不要喷,有错的地方还请不吝啬指教,谢谢....... 因为注释基本上已经说清楚啦,在这里就不多说什么啦,知识不够怕误人子弟 # -*- coding:utf-8 -*-im ...

  9. matlab绘制函数

    >> x1=linspace(,*pi,); x2=linspace(,*pi,); x3=linspace(,*pi,); y1=sin(x1); y2=+sin(x2); y3=+si ...

  10. layout_weight 的解释及使用

    layout_weight 的解释及使用 转自:http://my.oschina.net/jsan/blog/191492 在Android的控件布局中,有一个奇葩的 layout_weight 属 ...