Codeforcrs 761 A Dasha and Stairs
来源:互联网 发布:nginx和apache的关系 编辑:程序博客网 时间:2024/06/06 02:28
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 and4, and three odd:1, 3 and 5.
题意:给你两个数,判断是否有一段区间里有A个偶数且有B个奇数
讲解:很明显啦,数字都是一奇一偶排列的啦,
注意:0 0 的时候需要特判一下
AC代码:
#include<bits/stdc++.h>
using namespace std;int main(){ //freopen("d:\\oj项目\\对拍\\data.txt","r",stdin); //freopen("d:\\oj项目\\对拍\\out1.txt","w",stdout); int a,b; while(scanf("%d%d",&a,&b)!=EOF){ if(a == 0 && b == 0) { printf("NO\n"); continue; } if(a-1>b||b-1>a){ printf("NO\n"); } else{ printf("YES\n"); } } return 0;}
- Codeforcrs 761 A Dasha and Stairs
- A. Dasha and Stairs
- 【codeforces 761A】Dasha and Stairs
- Codeforces 761A-Dasha and Stairs
- poj 761A Dasha and Stairs
- CodeForces 761A Dasha and Stairs【水题】
- CodeForces-761A-Dasha and Stairs [水题]
- codeforces 761A Dasha and Stairs
- codeforces 753 A. Dasha and Stairs
- Codeforces-Round 394#A-Dasha and Stairs
- CF761 A. Dasha and Stairs (水题)
- Codeforces761A. Dasha and Stairs
- Codeforces761A Dasha and Stairs
- Dasha and Stairs
- Dasha and Stairs
- Codeforces Round #394(Div. 2)A.Dasha and Stairs【水题】
- Codeforces Round #394 (Div. 2) A. Dasha and Stairs 易错
- Codeforces Round #394 (Div. 2)(A. Dasha and Stairs,B. Dasha and friends,C. Dasha and Password)
- ki4so单点登陆系统
- 苹果核
- 03-树2 List Leaves (25分)
- bzoj 2743: [HEOI2012]采花 树状数组
- vlayout使用说明(一)
- Codeforcrs 761 A Dasha and Stairs
- Android——UI(一):UI绘制流程
- 学习方法总结和思考
- mybatis中insert into ...select ...from dual union all select ... from dual 提示sql命令未结束的问题
- 类似于网易新闻首页的滑动效果
- 设置XAMPP的phpmyadmin可以远程访问并为其设置密码
- 自问自答
- (五)禁用启用提供者
- Flume<自定义Source和拦截器实现抓取异常多行日志>