CF#267 (Div. 2) A
来源:互联网 发布:图片装饰软件 编辑:程序博客网 时间:2024/05/16 19:31
A. George and Accommodation
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
题目链接:http://codeforces.com/contest/467/problem/A
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行给出房间现住人数和房间容量,如果二者差大于等于2,那么二人便可以入住,求能够入住的房间数量。
完整代码:
#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int n; while(~scanf("%d",&n)) { int p , q , cnt = 0; for(int i = 0 ; i < n ; i ++) { scanf("%d%d",&p,&q); if(q - p >= 2) cnt ++; } printf("%d\n",cnt); }}
0 0
- CF#267 (Div. 2) A
- cf 190div 2 A
- CF #230 (Div. 2) A
- CF#257 (Div. 2) A.
- CF#256 (Div. 2) A.
- CF#FF (Div. 2) A .
- CF#253 (Div. 2) A.
- CF#258 (Div. 2) A.
- CF#252 (Div. 2) A.
- CF#250 (Div. 2) A .
- CF#259 (Div. 2) A.
- CF #260 (Div. 2)A
- CF #261 (Div. 2) A
- CF#264 (Div. 2) A.
- CF #263 (Div. 2) A
- CF #266 (Div. 2) A.
- CF#268 (Div. 2) A.
- CF#246 (Div. 2) A.
- 黑马程序员——Java基础——IO流(模拟BufferedReader类中的readLine()方法)
- iOS Block自身的内存问题
- HDU 5024 Wang Xifeng's Little Plot(暴力找点)
- 约瑟夫环问题
- NYOJ144 小珂的苦恼(扩展gcd的简单运用)
- CF#267 (Div. 2) A
- cocos2dx 系列教程
- N个实数中偶数的平均值
- 依然大爱的《棋魂》
- QT中各种MessageBox的使用
- Unity中添加组件的几种方法
- 2.3 IP网络性能测量
- IOS开发调用图片库或相机时界面设定为中文
- linux/unix僵尸进程(转自http://www.cnblogs.com/newpanderking/p/3784328.html)