Codeforces Round #394 (Div. 2) A. Dasha and Stairs
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.
In the only line you are given two integers a, b (0 ≤ a, b ≤ 100) — the number of even and odd steps, accordingly.
In the only line print "YES", if the interval of steps described above exists, and "NO" otherwise.
2 3
YES
3 1
NO
In the first example one of suitable intervals is from 1 to 5. The interval contains two even steps — 2 and 4, and three odd: 1, 3 and 5.
题意:已知有a个偶数b个奇数,判断这些数能不能组成连续正整数数列。
//没有考虑a==b和a=0并且b=0的时候
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int a,b;
int main()
{
scanf("%d%d",&a,&b);
if (abs(a-b)== || a==b && a!= && b!=) printf("YES\n");
else printf("NO\n");
return ;
}
Codeforces Round #394 (Div. 2) A. Dasha and Stairs的更多相关文章
- Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题
A. Dasha and Stairs 题目连接: http://codeforces.com/contest/761/problem/A Description On her way to prog ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)
E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle 构造
E. Dasha and Puzzle 题目连接: http://codeforces.com/contest/761/problem/E Description Dasha decided to h ...
- Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem 贪心
D. Dasha and Very Difficult Problem 题目连接: http://codeforces.com/contest/761/problem/D Description Da ...
- Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力
C. Dasha and Password 题目连接: http://codeforces.com/contest/761/problem/C Description After overcoming ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力
B. Dasha and friends 题目连接: http://codeforces.com/contest/761/problem/B Description Running with barr ...
- Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem —— 贪心
题目链接:http://codeforces.com/contest/761/problem/D D. Dasha and Very Difficult Problem time limit per ...
- Codeforces Round #394 (Div. 2) C. Dasha and Password —— 枚举
题目链接:http://codeforces.com/problemset/problem/761/C C. Dasha and Password time limit per test 2 seco ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends —— 暴力 or 最小表示法
题目链接:http://codeforces.com/contest/761/problem/B B. Dasha and friends time limit per test 2 seconds ...
随机推荐
- 简明python教程三-----函数
函数通过def关键字定义.def关键字后跟一个函数的表标识符名称,然后跟一对圆括号. 圆括号之中可以包括一些变量名,该行以冒号结尾.接下来是一块语句,它们是函数体. def sayHello(): p ...
- Mongo 查询
Mongo 查询 mongo js 遍历 db.getCollection('CPU').find({}).limit(100).sort({"time":-1}).forEa ...
- C/C++中浮点数输出格式问题
在C语言中,浮点数的输出格式有三种:%g, %f, %e 首先要说的是%e是采用科学计数法来显示. %g与后两者有一个重要的差别,就是设置输出精度的时候,(C中默认浮点输出精度是6),%g认为,包括整 ...
- Python之验证码
Python生成随机验证码,需要使用PIL模块. 安装: ? 1 pip3 install pillow 基本使用 1. 创建图片 ? 1 2 3 4 5 6 7 8 9 from PIL impor ...
- python代码结构
1. 使用#单行注释,使用'''...'''多行注释 2. 使用连接符\来把一行过长的代码分为多行 3. 用缩进来控制代码块,推荐使用PEP8缩进风格,即四个空格 4. if ...: elif... ...
- Xamrin开发安卓笔记(二)
http://www.cnblogs.com/minCS/p/4112617.html Xamrin开发安卓笔记(二) 安装篇 Xamrin开发安卓笔记(一) 昨天调理一天AAPT.EXE 被推出 ...
- 解释一下python中的关系运算符
关系运算符用于比较两个值 1.小于号,如果左边的值较小,则返回Trueprint('hi'<'Hi')#False 2.大于号,如果左边的值较大,则返回Trueprint(1.1+2.2> ...
- c3p0连接不上sql server
1.首先判断sqlserver是否安装成功 2如果sqlserver正常运行 可能是因为没有打开1433端口,按以下步骤设置tcp/ip enabled 打开之后再重新启动sql server服务,按 ...
- 设计模式(六) xml方式实现AOP
1.1. Aop, aspect object programming 面向切面编程 功能: 让关注点代码与业务代码分离! 关注点, 重复代码就叫做关注点: 切面, 关注点形成的类,就叫切面(类) ...
- Arrays.asList()与toArray()
Arrays.asList() 使用Arrays.asList()把数组转换成集合时,不能使用用于修改集合的方法(例如add.remove.clear),这将导致跑出UnsupportOperatio ...