A. Dasha and Stairs

题目连接:

http://codeforces.com/contest/761/problem/A

Description

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 a, b (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.

Sample Input

2 3

Sample Output

YES

Hint

题意

问你在现实生活中,存不存在一个起点和一个终点,使得里面的奇数有a个,偶数有b个。

题解:

1.暴力枚举

2.abs<=1即可,然后特判掉0 0这个数据,这个答案是no

代码

#include<bits/stdc++.h>
using namespace std;int main()
{long long a,b;cin>>a>>b;for(int l=0;l<=1000;l++){for(int r=l;r<=1000;r++){int L=0,R=0;for(int k=l;k<=r;k++){if(k%2==0)R++;else L++;}if(L==a&&R==b){cout<<"YES"<<endl;return 0;}}}cout<<"NO"<<endl;return 0;
}

转载于:https://www.cnblogs.com/qscqesze/p/6359964.html

Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题相关推荐

  1. Codeforces Round #370 (Div. 2) A. Memory and Crow 水题

    A. Memory and Crow 题目连接: http://codeforces.com/contest/712/problem/A Description There are n integer ...

  2. Codeforces Round #311 (Div. 2) A. Ilya and Diplomas 水题

    A. Ilya and Diplomas Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/ ...

  3. Codeforces Round #404 (Div. 2) B. Anton and Classes 水题

    B. Anton and Classes 题目连接: http://codeforces.com/contest/785/problem/B Description Anton likes to pl ...

  4. Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crosswor 水题

    A. One-dimensional Japanese Crossword 题目连接: http://codeforces.com/contest/721/problem/A Description ...

  5. Codeforces Round #358 (Div. 2) A. Alyona and Numbers 水题

    A. Alyona and Numbers 题目连接: http://www.codeforces.com/contest/682/problem/A Description After finish ...

  6. Codeforces Round #307 (Div. 2) A. GukiZ and Contest 水题

    A. GukiZ and Contest Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/551/ ...

  7. Codeforces Round #311 (Div. 2)B. Pasha and Tea 水题

    B. Pasha and Tea Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/557/prob ...

  8. Codeforces Round #350 (Div. 2) B. Game of Robots 水题

    B. Game of Robots 题目连接: http://www.codeforces.com/contest/670/problem/B Description In late autumn e ...

  9. Codeforces Round #379 (Div. 2) A. Anton and Danik 水题

    A. Anton and Danik 题目连接: http://codeforces.com/contest/734/problem/A Description Anton likes to play ...

最新文章

  1. 揭秘天猫双十一背后的那位贤内助
  2. 【HDU】4405 Aeroplane chess
  3. VR: AR和VR演进哲学
  4. Python操作Mysql实例代码教程在线版(查询手册)_python
  5. linux系统进程控制实验报告,Linux进程控制实验报告.doc
  6. C语言,全局变量与局部变量问题
  7. python loc iloc_【python】python vs Excel ( loc与iloc的使用)
  8. c语言中变量的属性,C中的属性变量
  9. 设计灵感|信息图表海报竟然能设计的这么有趣!
  10. 不同修饰符的访问权限(private,缺省(默认即default),protected,public)
  11. python编程软件哪个好-来 看看谁最适合学Python编程
  12. Nginx - 限制并发、限制访问速率、限制流量
  13. maven安装jar包到本地仓库
  14. 机器人学导论学习笔记No.1-第一章 :概述
  15. 使用Elasticsearch进行高效的中文搜索
  16. linux分区btrfs,linux btrfs文件系统及管理
  17. 无人驾驶感知篇之传感器标定(二)
  18. sizeof(long)
  19. 【Bootstrap】<前端框架>Bootstrap布局容器栅格网格系统
  20. 公众号如何裂变涨粉?

热门文章

  1. k8s部署oracle-ee-11g:部署、集群内外连接oracle的方式
  2. golang变量使用细节
  3. Python Django 图片上传及显示代码示例
  4. spring cloud的eureka.client.service-url.defaultZone配置eureka集群的写法
  5. Linux隐藏文件标识
  6. AngularJS基于MVC的复杂操作案例
  7. 二级list列表python_Python list 列表
  8. QML 发光呼吸动画字体
  9. Qt Post上传图片文件到服务器
  10. 完全备份指的是对整个计算机系统,网络安全管理实践题库:在备份技术中,差分备份就是对整个系统所有文件进行完全备份,包括所有系统和数据。()...