ACM(TWO)

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.

Examples

Input
3
1 1
2 2
3 3
Output
0
Input
3
1 10
0 10
10 10
Output
2

问题简述

输入一个总的房间数,接着输入每间房已住人数以及可住总人数。若两人可住入,计算可住的房间总数。

程序分析

定义房间数n,并使用for语句,使在n次数中,输入已住人数p和可住总人数q,并比较p与q的大小,同时定义一个整数型变量i=0,若p-q>=2,则i+1,最后i的值即为可住房间数。

AC程序如下:

//CodeForces-467A
#include<iostream>
using namespace std;
int main()
{
    int n, p, q, i = 0;
    cin >> n;
    for(int j=0;j<n;j++)
    {
        cin >> p >> q;
        if (p + 2 <= q)
            i++;
    }
    cout << i;
    return 0;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,872评论 0 10
  • 2017年12月21日 星期四 晴 下班回来到奶奶家接回孩子,李云哲一进门儿就喊饿了,饭还没做,只好先吃了...
    云哲云灿妈妈阅读 237评论 0 1
  • 需求 在树莓派上做了爬虫,爬取的内容越来越多,眼看32位mongodb的2G存储限制就要被突破了,于是希望能升级到...
    kownse阅读 5,592评论 5 4
  • 我把零零散散的过去用简单的词汇拼凑,汇聚成一段段朴素的文字在深夜静静的向你诉说。好像只有这样才不至于被这个城...
    星雨星海阅读 687评论 2 6
  • 今晚无课,自由安排,虚度光阴,幸有简书。 这几天频繁重逢自己的旧有模式,今天尤甚。最明显的一点是,打电话给老妈7次...
    漫步的小马驹阅读 798评论 4 14

友情链接更多精彩内容