博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第二题
阅读量:20602 次
发布时间:2019-12-03

本文共 1126 字,大约阅读时间需要 3 分钟。

George and Accommodation CodeForces - 467A

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.
问题简述:输入要测试多少个数据,然后就给出多少组数据,然后看数据符不符合题目要求
问题分析:……
程序说明:输入房间数,对每组输入的数据判断,输出符合条件的数据的组数
AC程序代码
#include
using namespace std;
int main()
{
int num, a[210],can=0;
cin >> num;
for (int i = 0;num*2!=i;i += 2)
{
cin >> a[i] >> a[i + 1];
if (a[i + 1] - a[i] >= 2)
can++;
}
cout << can << endl;
}

转载地址:http://lgevfk.baihongyu.com/

你可能感兴趣的文章
【redis入门】Centos下安装redis
查看>>
【redis入门】redis安装后相关知识串讲
查看>>
【redis】来吧,展示一下redis 发布-订阅模式
查看>>
讲通C/C++预编译/条件编译指令 #ifdef,#ifndef,#endif,#define,…
查看>>
【redis6.0.6】redis源码慢慢学,慢慢看 -- 第二天:空间配置(zmalloc)
查看>>
当下热点词再学:redis缓存预热、更新、降级,限流
查看>>
【redis6.0.6】redis源码慢慢学,慢慢看 -- 第五天:adlist
查看>>
别抖,OK? 操作系统抖动现象、网络抖动与延迟、函数抖动之防抖与节流,串讲
查看>>
第六天:网络处理(anet部分)-- redis源码慢慢学,慢慢看【redis6.0.6】
查看>>
通过域名获取主机IP -- struct addrinfo
查看>>
【C++】算法集锦(8):从两数和问题拓展到一百数和问题
查看>>
【C++】算法集锦(9):背包问题
查看>>
【C++】算法集锦(10)通俗讲kmp算法
查看>>
【C++】算法集锦(12):高楼扔鸡蛋
查看>>
【图解】拥塞控制
查看>>
线程上下文切换
查看>>
什么是服务熔断?
查看>>
服务器压力过大?CPU打满?我来帮你快速检查Linux服务器性能
查看>>
C++面经总结之《Effective C++》(一)
查看>>
C++面经总结之《Effective C++》(二)
查看>>