The number of positions
2014-11-23 14:34
218 查看
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 n, a and b (0 ≤ a, b < n ≤ 100).
Output
Print the single number — the number of the sought positions.
Sample test(s)
题解:Petr站在一个n人的队列里,已知站在他前面的人不少于a,站在他后面的人不多于b,求Petr站位的所有可能数目。
判断n-a和b的大小关系,如果前者大,考虑b,否则,考虑n-a。
代码:
Problem -124A - Codeforces
转载请注明出处:/article/5805443.html
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.
Sample test(s)
input |
3 1 1 |
output |
2 |
input |
5 2 3 |
output |
3 |
判断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-1; if(c > b) { r = b+1; }else { r = c+1; } printf("%d", r); return 0; }
Problem -124A - Codeforces
转载请注明出处:/article/5805443.html
相关文章推荐
- A. The number of positions
- CodeForces-124A-The number of positions
- Codeforces Beta Round #92 (Div. 2) / 124A The number of positions 【简单模拟】【水题】
- CodeForces-124A-The number of positions
- Codeforces Beta Round #92 (Div. 2) / 124A The number of positions (简单数学)
- HDU 3006 The Number of set(位运算 状态压缩)
- 生产环境elasticsearch5.0报错IllegalArgumentException: number of documents in the index cannot exceed 2147483519的处理
- Intel Code Challenge Final Round Xor-matic Number of the Graph -- 线性基
- Error: The number of filter groups does not divide the total number of filters.
- [LeetCode] Next Permutation - Next bigger number with the same set of digits
- How to arrange 10 digits so that the product of the some of them is equal to a number represented by the remaining digits
- #Paper Reading# X-means:Extending K-means with Efficient Estimation of the Number of Clusters
- The number of the archive index date format
- Codeforces.724G.Xor-matic Number of the Graph(线性基)
- hdu1492-The number of divisors(约数) about Humble Numbers
- codeforces 724G. Xor-matic Number of the Graph
- Leetcode--->Given n points on a 2D plane, find the maximum number of points that lie on the same str
- jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been excee
- [置顶]The Number of set-hdu-3006
- 27E - Number With The Given Amount Of Divisors