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;
}

总结

水题,不解释


目录
相关文章
Ant Design TreeSelect树形选择器格式化数据以及禁用父节点
Ant Design TreeSelect树形选择器格式化数据以及禁用父节点
1467 0
Ant Design TreeSelect树形选择器格式化数据以及禁用父节点
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
705 0
|
3月前
|
存储 运维 监控
API明细日志及运维统计日志全面提升API可运维性
在数字化转型的大潮中,数据已成为企业最宝贵的资产之一。而数据服务API可快速为数据应用提供数据接口。面对越来越多的API以及越来越多的应用调用,如何快速查看API的服务情况、异常情况及影响范围,以及查看API的调用详情,进行API的性能优化、错误排查变得越来越重要,本文将介绍如何配置和开通API运维统计及明细日志,以及如何查看日志进行介绍。
182 0
|
4月前
|
存储 Ubuntu Linux
关于实体机安装Ubuntu 22.04.3-desktop-amd64遇见的一些问题
【10月更文挑战第5天】本文介绍了Ubuntu安装过程中常见的四个问题及其解决方案,包括分区设置、驱动问题、软件安装问题和启动问题。对于分区,推荐新手选择自动分区,手动分区需了解基本概念。驱动问题可通过安装相应硬件的Linux驱动解决。软件安装问题可更换国内镜像源或修复依赖关系。启动问题则可尝试进入恢复模式修复或根据错误提示信息寻求帮助。
263 2
|
4月前
|
传感器 算法 芯片
基于stm32的多旋翼无人机(Multi-rotor UAV based on stm32)(上)
基于stm32的多旋翼无人机(Multi-rotor UAV based on stm32)(上)
362 0
|
4月前
|
存储 Docker 容器
docker中挂载数据卷到容器
【10月更文挑战第13天】
115 2
|
3月前
|
存储 算法 UED
数据结构之网络流量路径分析(BFS)
网络流量路径分析利用BFS算法在网络图中寻找从源节点到目标节点的最短路径,帮助识别网络瓶颈、优化数据流,提升网络性能。本示例通过构建一个无向图,展示了如何使用BFS算法进行路径分析,找到从节点0到节点5的有效路径,验证了算法的实用性和有效性。
76 0
|
4月前
|
Web App开发 移动开发 JavaScript
HTML 音频(Audio)详解
HTML5通过`&lt;audio&gt;`元素为网页音频播放提供了丰富支持。本文将介绍其基本用法、属性(如`controls`、`autoplay`)、事件监听、格式兼容性(MP3、OGG、WAV、AAC),并提供JavaScript控制示例。此外,还将讨论优化技巧,如使用CDN、懒加载及提升用户体验的方法。
|
3月前
|
存储 人工智能 自然语言处理
基于LLamaIndex构建企业级私有知识库:RAG Workflow工作流详解
【11月更文挑战第12天】随着生成式AI的快速发展,企业对智能化信息检索和生成的需求日益增加。传统的知识库系统往往局限于静态的数据存储和查询,难以满足复杂多变的业务需求。而检索增强生成(RAG, Retrieval-Augmented Generation)技术的出现,为企业级私有知识库的建设提供了新的解决方案。LLamaIndex作为专为LLMs(大型语言模型)设计的私有知识索引工具,结合RAG Workflow工作流,能够构建高效、智能的企业级私有知识库,满足企业对于知识管理和智能问答的多样化需求。
437 4
|
6月前
|
Linux Shell Perl
在Linux中,如何使用sed命令进行文本替换?
在Linux中,如何使用sed命令进行文本替换?