Codeforces Round #267 (Div. 2) A
题目:
1 second
256 megabytes
standard input
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.
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.
3
1 1
2 2
3 3
0
3
1 10
0 10
10 10
2
题意分析:
直接写写写吧。大水题,看到一堆人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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #267 (Div. 2)
A #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> ...
- Codeforces Round #267 Div.2 D Fedor and Essay -- 强连通 DFS
题意:给一篇文章,再给一些单词替换关系a b,表示单词a可被b替换,可多次替换,问最后把这篇文章替换后(或不替换)能达到的最小的'r'的个数是多少,如果'r'的个数相等,那么尽量是文章最短. 解法:易 ...
- Codeforces Round #267 (Div. 2) C. George and Job DP
C. George and Job The new ITone 6 has been released ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- uva 1557 - Calendar Game(博弈)
option=com_onlinejudge&Itemid=8&page=show_problem&problem=4332" target="_blank ...
- 足球和oracle系列(3):oracle过程排名,世界杯第二回合战罢到来!
足球与oracle系列(3):oracle进程排名.世界杯次回合即将战罢! 声明: 这不是技术文档,既然学来几招oracle简单招式.就忍不了在人前卖弄几下.纯为茶余饭后与数朋库友的插科 ...
- Intent有可能的使用(两)
Intent作为联系各Activity之间的纽带,其作用并不只只限于简单的数据传递. 通过其自带的属性.事实上能够方便的完毕非常多较为复杂的操作. 比如直接调用拨号功能.直接自己主动调用合适的程序打开 ...
- FREESWITCH SEESION
SESSION SESSION为FS的核心概念之一,所以需要拿出来专门的分析下. 从以下几个方面进行分析,结构类型,资源的管理,对于呼叫的意义,规格. 1.结构类型 每一次呼叫会申请一个session ...
- gopkg:一种方便的go pakcage管理方式
在使用go的过程中,我们有时候会引入一些第三方库来使用,而通常的方式就是使用go get,可是这样的方式有一个非常严重的问题,假设第三方库更新了相关接口,非常有可能你就无法使用了,所以我们一套非常好地 ...
- 【Win7】【磁盘管理】删除相似“33fbc1d57e9aaf1ea88e6f08”缓存目录
一般,在计算机磁盘.移动硬盘.或U盘出现,类别似"33fbc1d57e9aaf1ea88e6f08",你不能删除缓存目录.能Win7删除. (1).使用管理员,打开命令提示符窗口( ...
- GNU名称解析
GNU它是GNU's NOT UNIX缩写G N U缩写,和GNU全名GNU's NOT UNIX 中间 GNU 也GNU's NOT UNIX缩写,它使用递归方式定义GNU.
- Hibernate4.3.9Final常见问题汇总
hibernate4下一个可用的hibernate.properties: jdbc.driverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql ...
- xp硬盘安装Fedora14 过程记录及心得体会(fedora14 live版本680M 和fedora14 DVD版本3.2G的选择)
这次电脑奔溃了,奇怪的是直接ghost覆盖c盘竟然不中.之前电脑上硬盘安装的fedora14操作系统,也是双系统.不知道是不是这个问题,记得同学说过,在硬盘装fedora之后,要手动修改c盘隐藏的那个 ...
- wamp无法登录phpmyadmin问题
文章来源:PHP座谈会 地址:http://bbs.phpthinking.com/forum.php? mod=viewthread&tid=163 第一步.用navicat确认一下,自己的 ...