George and Accommodation

简介: George and Accommodation

文章目录

一、George and Accommodation

总结


一、George and Accommodation

本题链接:George and Accommodation


题目:

A. George and Accommodation

time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

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


本博客给出本题截图:

image.png

题意:如果q[i] - p[i] >= 2即找到一组解,问一共有多少组解

AC代码

#include <iostream>
using namespace std;
const int N = 110;
int p[N], q[N];
int res;
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i ++ )
    {
        cin >> p[i] >> q[i];
        if (q[i] - p[i] >= 2)
            res ++;
    }
    cout << res << endl;
    return 0;
}

总结

水题,不解释


目录
相关文章
|
JavaScript 前端开发
用JavaScript正则表达式匹配对应字符串高亮显示,并过滤掉空格、<、>等HTML节点符号
用JavaScript正则表达式匹配对应字符串高亮显示,并过滤掉空格、<、>等HTML节点符号
Ant Design TreeSelect树形选择器格式化数据以及禁用父节点
Ant Design TreeSelect树形选择器格式化数据以及禁用父节点
1714 0
Ant Design TreeSelect树形选择器格式化数据以及禁用父节点
|
6月前
|
API
Dataphin功能Tips系列(64)-API资产编目及上架
在企业数据部门中,因API命名不规范、分类不清、信息不全等问题,导致业务开发人员查找困难、重复咨询、误用接口等,影响效率。Dataphin提供API资产编目与上架功能,通过目录规划、属性管理、手动/自动上架等方式,实现API的系统化管理与精准检索,提升业务响应效率。
142 0
|
存储 Ubuntu Linux
关于实体机安装Ubuntu 22.04.3-desktop-amd64遇见的一些问题
【10月更文挑战第5天】本文介绍了Ubuntu安装过程中常见的四个问题及其解决方案,包括分区设置、驱动问题、软件安装问题和启动问题。对于分区,推荐新手选择自动分区,手动分区需了解基本概念。驱动问题可通过安装相应硬件的Linux驱动解决。软件安装问题可更换国内镜像源或修复依赖关系。启动问题则可尝试进入恢复模式修复或根据错误提示信息寻求帮助。
652 2
|
存储 Docker 容器
docker中挂载数据卷到容器
【10月更文挑战第13天】
493 2
|
存储 算法 UED
数据结构之网络流量路径分析(BFS)
网络流量路径分析利用BFS算法在网络图中寻找从源节点到目标节点的最短路径,帮助识别网络瓶颈、优化数据流,提升网络性能。本示例通过构建一个无向图,展示了如何使用BFS算法进行路径分析,找到从节点0到节点5的有效路径,验证了算法的实用性和有效性。
388 0
|
Linux Shell Perl
在Linux中,如何使用sed命令进行文本替换?
在Linux中,如何使用sed命令进行文本替换?
|
存储 固态存储 芯片
计算机中内存与存储
【7月更文挑战第28天】
2657 1
|
前端开发 数据库
【Stream流】Sort排序详解
【Stream流】Sort排序详解
349 0
|
监控 应用服务中间件 nginx