A. Dasha and Stairs
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

On her way to programming school tiger Dasha faced her first test — a huge staircase!

The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values — the number of steps with even and odd
numbers.

You need to check whether there is an interval of steps from the l-th to the r-th (1 ≤ l ≤ r),
for which values that Dasha has found are correct.

Input

In the only line you are given two integers ab (0 ≤ a, b ≤ 100) —
the number of even and odd steps, accordingly.

Output

In the only line print "YES", if the interval of steps described above exists, and "NO"
otherwise.

Examples
input
2 3
output
YES
input
3 1
output
NO

————————————————————————————————————————————
题目的意思是能否找到在一串连续的整数使得奇数和偶数的数量为输入的
奇偶数量差值超过1就是不可能的了 注意判0 0的情况也是不可能的

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 100005 int main()
{
int a,b;
while(~scanf("%d%d",&a,&b))
{
if(a==0&&b==0)
printf("NO\n");
else if(a-b>=2||b-a>=2)
printf("NO\n");
else
printf("YES\n");
} return 0;
}


Codeforces761A Dasha and Stairs 2017-02-05 23:28 114人阅读 评论(0) 收藏的更多相关文章

  1. 循环队列 分类: c/c++ 2014-10-10 23:28 605人阅读 评论(0) 收藏

    利用线性表实现队列,为了有效利用空间,将其设计为循环结构,防止假溢出:牺牲一个存储单元以区分队空.队满. 设front队头,rear队尾,N为顺序表大小 队空:rear==front 队满:(rear ...

  2. Codeforces761B Dasha and friends 2017-02-05 23:34 162人阅读 评论(0) 收藏

    B. Dasha and friends time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  3. NYOJ-235 zb的生日 AC 分类: NYOJ 2013-12-30 23:10 183人阅读 评论(0) 收藏

    DFS算法: #include<stdio.h> #include<math.h> void find(int k,int w); int num[23]={0}; int m ...

  4. ZOJ2482 IP Address 2017-04-18 23:11 44人阅读 评论(0) 收藏

    IP Address Time Limit: 2 Seconds      Memory Limit: 65536 KB Suppose you are reading byte streams fr ...

  5. ZOJ3704 I am Nexus Master! 2017-04-06 23:36 56人阅读 评论(0) 收藏

    I am Nexus Master! Time Limit: 2 Seconds      Memory Limit: 65536 KB NexusHD.org is a popular PT (Pr ...

  6. 使用URLConnection获取网页信息的基本流程 分类: H1_ANDROID 2013-10-12 23:51 3646人阅读 评论(0) 收藏

    参考自core java v2, chapter3 Networking. 注:URLConnection的子类HttpURLConnection被广泛用于Android网络客户端编程,它与apach ...

  7. 认识C++中的临时对象temporary object 分类: C/C++ 2015-05-11 23:20 137人阅读 评论(0) 收藏

    C++中临时对象又称无名对象.临时对象主要出现在如下场景. 1.建立一个没有命名的非堆(non-heap)对象,也就是无名对象时,会产生临时对象. Integer inte= Integer(5); ...

  8. Uniform Generator 分类: HDU 2015-06-19 23:26 11人阅读 评论(0) 收藏

    Uniform Generator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...

  9. hilbert矩阵 分类: 数学 2015-07-31 23:03 2人阅读 评论(0) 收藏

    希尔伯特矩阵 希尔伯特矩阵是一种数学变换矩阵 Hilbert matrix,矩阵的一种,其元素A(i,j)=1/(i+j-1),i,j分别为其行标和列标. 即: [1,1/2,1/3,--,1/n] ...

随机推荐

  1. const 补充

    char const* ptr1const char * ptr2char * const ptr3 看到这三个const作何感想 其实const比较好理解的是const 后面整体是不能改变的(整体的 ...

  2. /etc/sysctl.conf参数解释(转)

    来自<深入理解Nginx模块开发与架构解析> P9 #表示进程(例如一个worker进程)可能同时打开的最大句柄数,直接限制最大并发连接数fs.file max = 999999 #1代表 ...

  3. Form中的keypress事件不能用

    Form中的keypress事件不能用 编写人:CC阿爸 2015-4-8 近期在修改系统时,想给一画面增加一个组合键功能,但在form_keypress事件中加入代码,但无论如何也不能触发该动作. ...

  4. Jenkins构建Python项目提示:'python' 不是内部或外部命令,也不是可运行的程序

    问题描述: jenkin集成python项目,立即构建后,发现未执行成功,查看Console Output 提示:'Python' 不是内部或外部命令,也不是可运行的程序,如下图: 1.在 Windo ...

  5. 如何制作行政区划矢量图(shp格式)

    详细图文ArcGIS10.2破解版教程地址:http://jingyan.baidu.com/article/e73e26c0cb5c1324adb6a791.html 有时候想要一张shp格式的地方 ...

  6. Waiting for device dev/disk/by-id/ata-...-part2 to appear

    问题: 平台:Oralce VM Virtualbox的虚拟机Opensuse11.4 导出该机器的OVA文件后,把该OVA文件导入虚拟机,开机启动时报如下错误: Trying manual resu ...

  7. POJ 2777-题解

    一.题意 给你一排N个格子,M种颜色,P个操作.有两种操作:(1)C A B D:把[A, B]区间内的所有格子涂成颜色D.(2)P A B:输出[A, B]区间内的颜色的种类数.注意,初始颜色为1. ...

  8. MongoDB 生态 – 可视化管理工具

    工欲善其事,必先利其器,我们在使用数据库时,通常需要各种工具的支持来提高效率:很多新用户在刚接触 MongoDB 时,遇到的问题是『不知道有哪些现成的工具可以使用』,本系列文章将主要介绍 MongoD ...

  9. 225. Implement Stack using Queues + 232. Implement Queue using Stacks

    ▶ 栈和队列的相互表示.发现内置的队列和栈结构都十分高效,相互表示后性能损失都很小. ▶ 第 225 题,用队列实现栈 ● 自己的代码,3 ms,单队列实现,入栈 O(1),读取栈顶元素 O(n),出 ...

  10. 25个必须记住的SSH命令

      OpenSSH是SSH连接工具的免费版本.telnet,rlogin和ftp用户可能还没意识到他们在互联网上传输的密码是未加密的,但SSH 是加密的,OpenSSH加密所有通信(包括密码),有效消 ...