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. pgsql的同步须知

    pgsql的同步模式是根据master上的日志来做的同步,有两种同步方式,参考http://www.chinaxing.org/articles/Postgres/2012/12/14/2012-12 ...

  2. Python格式化输出%s和%d

    python print格式化输出. 1. 打印字符串 print ("His name is %s"%("Aviad")) 效果: 2.打印整数 print ...

  3. 五、jdk工具之jmap(java memory map)、 mat之四--结合mat对内存泄露的分析、jhat之二--结合jmap生成的dump结果在浏览器上展示

    目录 一.jdk工具之jps(JVM Process Status Tools)命令使用 二.jdk命令之javah命令(C Header and Stub File Generator) 三.jdk ...

  4. [置顶] Ubuntu16.04+opencv3.3.0的安装配置说明

    系统环境:  Linux Ubuntu 16.04  [GCC 5.4.0 20160609] on linux2 之前的教程中我们已经安装了做机器学习需要使用的框架TensorFlow,笔者本科阶段 ...

  5. Getting Started(入门)

    欢迎阅读专门针对android开发者的培训课程,在这一系列的课程中,描述了如何通过我们的示例代码来完成特定的任务和功能,这些代码可以灵活地应用到你的应用程序中. 课程被分成了几部分, 第一部分,入门, ...

  6. 20165233 预备作业3 Linux安装及学习

    Linux学习记录 别出心裁的Linux命令学习法学习总结 (由于我的电脑是Mac,Linux安装省略) 操作系统的功能: 管家婆和服务生 博客中对于这两个词含义的解释为 管家婆:通过进程.虚拟内存和 ...

  7. python爬虫 发送定时气象预报

    python爬取天气情况 下面为示例代码: from urllib.request import urlopen from bs4 import BeautifulSoup from urllib.e ...

  8. 设置GO环境变量

    linux的设置方法:有4个环境变量需要设置:GOROOT.GOPATH.GOBIN以及PATH.需要设置到某一个profile文件中(~/.bash_profile(单一用户)或/etc/profi ...

  9. mysql 获取一段时间的数据

    用 sql 获取一段时间内的数据: SELECT * FROM EDI.edi_history WHERE timestampdiff(day, SYSDATE(), create_time_loc) ...

  10. Firemonkey Button 颜色

    delphi FMX Firemonkey Button 按钮 颜色 TintColor 颜色 Button1.TintColor:=TAlphaColorRec.Green;