A. Dasha and Stairs

Codeforces
IDCF761A
Time2000ms
Memory256MB
Difficulty
brute forceconstructive algorithmsimplementationmath
English · Original
Chinese · Translation
Formal · Original
On her way to programming school tiger Dasha faced her first test — a huge staircase! <center>![image](https://espresso.codeforces.com/34326935a965721f32f8203b55c38fdf9861d657.png)</center>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. [samples] ## 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.
在前往编程学校的路上,老虎达莎遇到了她的第一道测试题——一座巨大的楼梯! 楼梯的台阶从 1 编号到无穷大。众所周知,老虎非常喜欢条纹状的东西,这或许与它们的毛色有关。因此,在她路程的某一段区间内,她计算了两个值:偶数编号台阶和奇数编号台阶的数量。 你需要检查是否存在一个从第 #cf_span[l]-th 个台阶到第 #cf_span[r]-th 个台阶的区间 #cf_span[(1 ≤ l ≤ r)],使得达莎所找到的数值是正确的。 在唯一的一行中,给你两个整数 #cf_span[a], #cf_span[b] #cf_span[(0 ≤ a, b ≤ 100)] —— 分别表示偶数台阶和奇数台阶的数量。 在唯一的一行中,如果上述描述的台阶区间存在,输出 "_YES_",否则输出 "_NO_"。 在第一个例子中,一个合适的区间是从 #cf_span[1] 到 #cf_span[5]。该区间包含两个偶数台阶 —— #cf_span[2] 和 #cf_span[4],以及三个奇数台阶:#cf_span[1]、#cf_span[3] 和 #cf_span[5]。 ## Input 在唯一的一行中,给你两个整数 #cf_span[a], #cf_span[b] #cf_span[(0 ≤ a, b ≤ 100)] —— 分别表示偶数台阶和奇数台阶的数量。 ## Output 在唯一的一行中,如果上述描述的台阶区间存在,输出 "_YES_",否则输出 "_NO_"。 [samples] ## Note 在第一个例子中,一个合适的区间是从 #cf_span[1] 到 #cf_span[5]。该区间包含两个偶数台阶 —— #cf_span[2] 和 #cf_span[4],以及三个奇数台阶:#cf_span[1]、#cf_span[3] 和 #cf_span[5]。
**Definitions** Let $ a, b \in \mathbb{Z}_{\geq 0} $ denote the counts of even and odd-numbered steps, respectively. **Constraints** $ 0 \leq a, b \leq 100 $ **Objective** Determine whether there exists an interval $ [l, r] \subseteq \mathbb{Z}^+ $ with $ 1 \leq l \leq r $, such that the number of even integers in $ [l, r] $ is $ a $, and the number of odd integers in $ [l, r] $ is $ b $. **Condition for Existence** Such an interval exists if and only if: $$ |a - b| \leq 1 $$
Samples
Input #1
2 3
Output #1
YES
Input #2
3 1
Output #2
NO
API Response (JSON)
{
  "problem": {
    "name": "A. Dasha and Stairs",
    "description": {
      "content": "On her way to programming school tiger Dasha faced her first test — a huge staircase! <center>![image](https://espresso.codeforces.com/34326935a965721f32f8203b55c38fdf9861d657.png)</center>The steps ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF761A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "On her way to programming school tiger Dasha faced her first test — a huge staircase!\n\n<center>![image](https://espresso.codeforces.com/34326935a965721f32f8203b55c38fdf9861d657.png)</center>The steps ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "在前往编程学校的路上,老虎达莎遇到了她的第一道测试题——一座巨大的楼梯!\n\n楼梯的台阶从 1 编号到无穷大。众所周知,老虎非常喜欢条纹状的东西,这或许与它们的毛色有关。因此,在她路程的某一段区间内,她计算了两个值:偶数编号台阶和奇数编号台阶的数量。\n\n你需要检查是否存在一个从第 #cf_span[l]-th 个台阶到第 #cf_span[r]-th 个台阶的区间 #cf_span[(1 ≤ l ≤...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ a, b \\in \\mathbb{Z}_{\\geq 0} $ denote the counts of even and odd-numbered steps, respectively.  \n\n**Constraints**  \n$ 0 \\leq a, b \\leq 100 $  \n\n**Objective**  \nDetermine whethe...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments