【codeforces 761A】Dasha and Stairs
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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 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.
Examples
input
2 3
output
YES
input
3 1
output
NO
Note
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.
【题目链接】:http://codeforces.com/contest/761/problem/A
【题解】
一段区间里面,偶数和奇数的个数的差的绝对值不会超过1;
但是有个Hack点0 0;
一段区间里面不可能既没有奇数也没有偶数;
【完整代码】
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main()
{
cin >> a >> b;
int temp = abs(a-b);
if (temp<=1)
{
if (a==0 && b==0)
puts("NO");
else
puts("YES");
}
else
puts("NO");
return 0;
}
【codeforces 761A】Dasha and Stairs的更多相关文章
- 【codeforces 761C】Dasha and Password(动态规划做法)
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 761C】Dasha and Password(贪心+枚举做法)
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 761B】Dasha and friends
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 761D】Dasha and Very Difficult Problem
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 761E】Dasha and Puzzle
[题目链接]:http://codeforces.com/contest/761/problem/E [题意] 给你一棵树,让你在平面上选定n个坐标; 使得这棵树的连接关系以二维坐标的形式展现出来; ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
随机推荐
- js读取解析JSON数据(转)
JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式,采用完全独立于语言的文本格式,是理想的数据交换格式.同时,JSON是 JavaScript 原生格式,这意 ...
- ajax成功请求到后台,但是前端报404错误
记录下今天遇见的一个问题,一个删除的ajax请求,传递一个主键到后台,后台成功接受并执行删除,但是前端报POST404错误. 查找原因是由于Controller忘记写返回状态码 @Responsebo ...
- sqlserver 大数据量的insert、delete操作优化
http://blog.csdn.net/lanyuzhen/article/details/7547476 --大批量导出orders表:insert DBCC DROPCLEANBUFFERS ...
- oracle-ASM存储器
自动存储管理 Oracle 10g引进的一种新型存储机制.它依靠oracle来维护企业的数据库存储器,被设计用来解除磁盘和存储器管理的负担,可以使用ASM来定义用于文件管理的磁盘组. 磁盘组类似于某些 ...
- TCP keepalive的机理及使用
TCP 是面向连接的 , 在实际应用中通常都需要检测对端是否还处于连接中.如果已断开连接,主要分为以下几种情况: 1.连接的对端正常关闭,即使用 closesocket 关闭连接. 2.连接的对端非正 ...
- 【JZOJ4793】【GDOI2017模拟9.21】妮厨的愤怒
题目描述 栋栋和标标都是厨力++的妮厨.俗话说"一机房不容二厨",他们两个都加入了某OI( )交流♂( )群,在钦定老婆的时候出现了偏差,于是闹得不可开交.可是栋栋是群内的长者,斗 ...
- node 写的简单爬虫(三)
异步爬取数据 先引入 var async = require('async'); 然后同样上代码 var topicUrls = [];//存所有地址 http.get(url,function(re ...
- Ubuntu 16.04下OLSR协议安装教程
OLSR是根据MANET的要求,在传统的LS(Link state)协议的基础上优化的. OLSR中的关键概念是多点转播(MPRs),MPRs是在广播洪泛的过程中挑选的转发广播的节点.传统的链路状态协 ...
- JavaScript--开关思想
就是男默女泪的立flag! <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
- List容器案例
案例讲解 迭代模式 不暴露集合的内部结构,又让外部访问集合中的数据 package com.day1; public interface Iterator <T>{ public bool ...