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 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;
}
Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题的更多相关文章
- Codeforces Round #394 (Div. 2) A. Dasha and Stairs
A. Dasha and Stairs time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs 水题
A. Dreamoon and Stairs 题目连接: http://www.codeforces.com/contest/476/problem/A Description Dreamoon wa ...
- 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 #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
随机推荐
- [转载]Juicer – 一个Javascript模板引擎的实现和优化
http://ued.taobao.org/blog/2012/04/juicer-%E4%B8%80%E4%B8%AAjavascript%E6%A8%A1%E6%9D%BF%E5%BC%95%E6 ...
- [python]小技巧集锦
1.数组过滤,只适用于numpy alpha[alpha>0]:返回alpha中大于0的元素组成的数组 2.在范围内选取不等于某值的数值 j = i while j==i: j = int(ra ...
- mybatis批量增加与删除——(十五)
1.首先应该明白,mybatis增删改返回值是int型的影响行数的值 mapper接口 package cn.xm.mapper; import java.util.List; import cn.x ...
- gitminer
https://github.com/UnkL4b/GitMiner + Autor: UnK + Blog: https://unkl4b.github.io + Github: https://g ...
- Update Bits
Given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to set all bits be ...
- 关于USBHID协议以及鼠标键盘描述符的解释【转】
转自:https://blog.csdn.net/jiujiujiuqiuqiuqiu/article/details/47277685 一.HID设备识别 前面有提到关于SCSI协议的USB设备实现 ...
- Ansible 插件 之 【CMDB】【转】
Github地址: https://github.com/fboender/ansible-cmdb 从facts收集信息,生成主机概述 安装 wget https://github.com/fboe ...
- (转载)ibatis:解决sql注入问题
原文地址:http://blog.csdn.net/scorpio3k/article/details/7610973 对于ibaits参数引用可以使用#和$两种写法,其中#写法会采用预编译方式,将转 ...
- (转载)mysql:“Access denied for user 'root'@'localhost'”
原文地址:http://www.linuxidc.com/Linux/2007-05/4338.htm # /etc/init.d/mysql stop# mysqld_safe --user=mys ...
- springboot---->集成mybatis开发(一)
这里面我们介绍一下springboot与mybatis的集成,主要完成了mybatis的真分页.一个成熟的人往往发觉可以责怪的人越来越少,人人都有他的难处. springboot简单集成mytbati ...