Text Reverse
Time limit1000 msMemory limit262144 kBSourceCodeforces Round #267 (Div. 2)Tagsimplementation *800EditorialAnnouncement
George and Accommodation
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.
Input
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.
Output
Print a single integer — the number of rooms where George and Alex can move in.
Sample Input
3
1 1
2 2
3 3
Sample Output
0
问题链接:https://vjudge.net/problem/CodeForces-467A
问题简述:在现有的房间中,选择能同时铸两个人的房间,求出符合房间的数目。
问题分析:要能循环输入每个房间的状况,并用判断语句统计符合的数目。
程序说明:用for语句循环输入,用两个数相减大于或者等于2作为判断条件,循环内自增来统计。
AC通过的C语言程序如下:
#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
int room, pi, qi,a,b=0;
cin >> a;
for (int i = 0; i < a; i++) {
cin >> pi;
cin >> qi;
if ((qi - pi) >= 2)
b++;
}
cout << b;
}