题目:

A. George and Accommodation
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard 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.

Sample test(s)
input
3
1 1
2 2
3 3
output
0
input
3
1 10
0 10
10 10
output
2

题意分析:

有N个寝室,每一个寝室已经有p个人住了,总共能住下q个人。如今还有两个人能不能住下。

直接写写写吧。大水题,看到一堆人1,2分钟就过了.


代码:

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; int main()
{
int n,ans,q,p;
while(scanf("%d",&n)!=EOF)
{
ans=0;
for(int i=0;i<n;i++)
{
scanf("%d%d",&q,&p);
if(p-q>=2)
ans++;
}
printf("%d\n",ans);
}
}

Codeforces Round #267 (Div. 2) A的更多相关文章

  1. 01背包 Codeforces Round #267 (Div. 2) C. George and Job

    题目传送门 /* 题意:选择k个m长的区间,使得总和最大 01背包:dp[i][j] 表示在i的位置选或不选[i-m+1, i]这个区间,当它是第j个区间. 01背包思想,状态转移方程:dp[i][j ...

  2. Codeforces Round #267 (Div. 2) C. George and Job(DP)补题

    Codeforces Round #267 (Div. 2) C. George and Job题目链接请点击~ The new ITone 6 has been released recently ...

  3. Codeforces Round #267 (Div. 2)

    A #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> ...

  4. Codeforces Round #267 Div.2 D Fedor and Essay -- 强连通 DFS

    题意:给一篇文章,再给一些单词替换关系a b,表示单词a可被b替换,可多次替换,问最后把这篇文章替换后(或不替换)能达到的最小的'r'的个数是多少,如果'r'的个数相等,那么尽量是文章最短. 解法:易 ...

  5. Codeforces Round #267 (Div. 2) C. George and Job DP

                                                  C. George and Job   The new ITone 6 has been released ...

  6. Codeforces Round #267 (Div. 2)D(DFS+单词hash+简单DP)

    D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Round #267 (Div. 2) D. Fedor and Essay tarjan缩点

    D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #267 (Div. 2) B. Fedor and New Game【位运算/给你m+1个数让你判断所给数的二进制形式与第m+1个数不相同的位数是不是小于等于k,是的话就累计起来】

    After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...

  9. Codeforces Round #267 (Div. 2) B. Fedor and New Game

    After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play ...

随机推荐

  1. css中换行的几种方式

    1.white-space:normal;   这个只针对中文有效 2.word-break:break-all;  强制换行,针对中文,数字,英文等都有效: 3.word-wrap:break-wo ...

  2. cocos2d-x-3.0新建工程以及移植其他平台

    本文来自:http://www.zaojiahua.com/cocos2d-x-3-0.html 有将近俩个礼拜没有研究cocos2dx了,博主最近刷了些ACM的水题,越做感觉越没意思,这哪是考编程啊 ...

  3. windows phone (27) 基础Button

    原文:windows phone (27) 基础Button Button 在wp7中因其灵活性经常会用到,我们在ContentPanel中直接添加Button,button默认状态下是把整个grid ...

  4. Net程序员学习Linux

    Net程序员学习Linux 本次知识点:Linux系统的多终端切换,linux下的用户,linux远程访问工具使用,linux下重要的目录,命令的组成,通配符,linux的路径问题,文件操作的综合运用 ...

  5. C语言程序代写(qq:928900200)

    1cs3157 – Advanced ProgrammingSummer 2014, Project 1, 150 pointsJune 17, 2014Follow these step-by-st ...

  6. Mongoose即使是简单的表查询

    从我原来的博客尖,欢迎大家光临 http://www.hacke2.cn 像我这篇文章所说的基于Node.js + jade + Mongoose 模仿gokk.tv.当时停止开发是由于我深深的感觉到 ...

  7. IE7,8,9兼容性处理

    在IE7根据假设高度文本框中设置,则光标将不会被中心的方法如以下: 添加属性,如:style="line-height:32px\9";能够 假设一个页面有多个TAB交换的物品.而 ...

  8. 应对黑客攻击SQL SERVER数据库中的一个案例

    最近发现挂在网上server不知怎的,重新启动,那server现在主要是开始IIS服务,SQL SERVER 服务. 远程登录.发现系统响应十分缓慢.一个明显的停滞感,打开任务管理器,CPU在基本用法 ...

  9. 怎样解决No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386).

    怎样解决No architectures to compile for (ONLY_ACTIVE_ARCH=YES, active arch=x86_64, VALID_ARCHS=i386). 错误 ...

  10. .NET 并行(多核)编程系列之六 Task基础部分完结篇

    原文:.NET 并行(多核)编程系列之六 Task基础部分完结篇 .NET 并行(多核)编程系列之六 Task基础部分完结篇 前言:之前的文章介绍了了并行编程的一些基本的,也注重的讲述了Task的一些 ...