vj467A--George and Accommodation

2023-10-17 17:10
文章标签 vj467a george accommodation

本文主要是介绍vj467A--George and Accommodation,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

问题来源

vj467A

问题描述

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.

输入

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.

输出

Print a single integer — the number of rooms where George and Alex can move in.

例子

在这里插入图片描述

AC的代码

#include<iostream>
using namespace std;
int main()
{int i,t,k,s=0;cin>>i;while(i){cin>>t;cin>>k;if((k-t)>=2)s++;i--;}
cout<<s;}

解题思路

用i保存示例数,i次循环分别输入已有人数和可住人数,若有一个房间可住人数减去已有人数大于等于2,则s加一,循环结束输出s,则为可住房间数。

这篇关于vj467A--George and Accommodation的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/226800

相关文章

George Hotz 自动驾驶 深度学习

George Hotz:请收下我的智驾系统代码(附论文) 举报   1 新智元原创      【新智元导读】我知道以GeoHot的脾气,最终 comma.ai 全套AI模型的代码肯定会被他开源,但我没想到会这么快,而且我也没想到这么完备,几乎毫无保留,多达80G的驾驶数据,模型以及论文全部开放,黑客精神在这位老兄身上的到了淋漓尽致的体现。本文结合GeoHot此次发表的论文

美国SAP高手跳槽记-转自George

http://paowang.com/blog/george/ 跳槽(1) 跳槽的典故,据我上周得到的教育,是来自三言二拍,形容当时的富家公子又喜欢上了新来的妓女而抛弃了旧的相好的行为。现在这个词就是换工作的意思了。 事情的起因是一两个月前,我因为晚上睡觉没有锁前面院子的落地窗,被房东说了一次,并因为他最近刚刚办公室被盗而把这件事情看得很严重,以终止租约威胁我必须严格保证将来不再

CodeForces 387A George and Sleep

链接:http://codeforces.com/problemset/problem/387/A George and Sleep time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Geor

CodeForces 387C George and Number

链接:http://codeforces.com/problemset/problem/387/C George and Number time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Geo

CodeForces 387B George and Round

链接:http://codeforces.com/problemset/problem/387/B George and Round time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output G

【智驾深谈】George Hotz 开源代码复现与分析(80G数据云盘下载)

GeoHot智驾系统开源这件事情还是很多人关注的,也问了很多问题,其中包括渐进式路线的车企,直接L4的互联网企业,很多创业团队和风投。先回答一个问到最多的问题:这代码离实际路上能用还差很多。 对于大公司来讲,车企做渐进式ADAS其实都是工况分解而来,流行使用状态机,深度模型是个黑盒子他们肯定不喜欢。 互联网企业愿意尝试新方法,但这个系统其实还需要在车辆控制方面做大量的改进才能够

George Hotz 自动驾驶 深度学习

George Hotz:请收下我的智驾系统代码(附论文) 举报   1 新智元原创      【新智元导读】我知道以GeoHot的脾气,最终 comma.ai 全套AI模型的代码肯定会被他开源,但我没想到会这么快,而且我也没想到这么完备,几乎毫无保留,多达80G的驾驶数据,模型以及论文全部开放,黑客精神在这位老兄身上的到了淋漓尽致的体现。本文结合GeoHot此次发表的论文

【云烤鸭】和雅思口语恋爱的第1天——Part 1 Houses ——What kind of accommodation do you live in?

Houses ——What kind of accommodation do you live in?​​​​​​​FREE IELTS Speaking practice online: Topic - HOMES and HOUSEShttps://www.youtube.com/watch?v=ArTA9OW-srQ&t=3745s House:Detached house;Flat-a