Codeforces Round #267 (Div. 2) A
来源:互联网 发布:怎么把mac升级到10.11 编辑:程序博客网 时间:2024/06/06 07:30
题目:
George has recently entered the BSUCP (Berland State University for Cool Programmers). George has a friend Alex who has also entered the university. Now they are moving into a dormitory.
George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex.
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of rooms.
The i-th of the next n lines contains two integers pi and qi (0 ≤ pi ≤ qi ≤ 100) — the number of people who already live in the i-th room and the room's capacity.
Print a single integer — the number of rooms where George and Alex can move in.
31 12 23 3
0
31 100 1010 10
2
题意分析:
代码:
#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>using namespace std;int main(){ int n,ans,q,p; while(scanf("%d",&n)!=EOF) { ans=0; for(int i=0;i<n;i++) { scanf("%d%d",&q,&p); if(p-q>=2) ans++; } printf("%d\n",ans); }}
- Codeforces Round #267 (Div. 2) A
- Codeforces Round #267 (Div. 2) A. George and Accommodation
- Codeforces Round #267 (Div. 2) A B C
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- Codeforces Round #172 (Div. 2) A题
- Codeforces Round #166 (Div. 2) A题
- Codeforces Round #132 (Div. 2) A题
- Codeforces Round #131 (Div. 2) A题
- Codeforces Round #133 (Div. 2) A题
- Codeforces Round #137 (Div. 2) A题
- Codeforces Round #138 (Div. 2) A题
- Codeforces Round #147 (Div. 2) A题
- Codeforces Round #141 (Div. 2) A题
- http://bar.cnyes.com/html/100102-1/8D1A047651DE6F2.shtml
- http://bar.cnyes.com/html/100102-1/8D1A047651DE6F2.shtml
- UVALive-6656-Watching the Kangaroo(二分)
- linux 查看公网ip
- E: 无法获得锁 /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)解决方法
- Codeforces Round #267 (Div. 2) A
- Codeforces Round #267 (Div. 2) B
- c++ bit field
- Codeforces Round #267 (Div. 2) C
- 算法书籍推荐
- 有太多如同热度已投入的一天
- Stable Matching: Gale and Shapley Algorithm
- SQL Server Insert data into table
- 用javascript在对象中添加属性