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 ...
随机推荐
- bzoj千题计划269:bzoj2655: calc (拉格朗日插值)
http://www.lydsy.com/JudgeOnline/problem.php?id=2655 f[i][j] 表示[1,i]里选严格递增的j个数,序列值之和 那么ans=f[A][n] * ...
- dedecms在linux上安装提示没权限解决办法
web服务器运行的用户与目录所有者用户必须不一样,比如apache运行的用户为root,那么网站目录设置的所有者就应该不能设置为root,而是设置不同于root的用户,如apache. 我们这里假设w ...
- Docker学习笔记一 概念、安装、镜像加速
本文地址:https://www.cnblogs.com/veinyin/p/10406378.html Docker 是一个容器,可以想象成一个轻便的虚拟机,但不虚拟硬件和操作系统. 优点:启动快 ...
- CF 1131B Draw!
Draw! Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Descriptio ...
- 第5月第15天 php email
1. <?php require_once "Mail.php"; $from = "luckyeggs<fuping304@163.com>" ...
- 洛谷 P4128: bzoj 1815: [SHOI2006]有色图
题目传送门:洛谷 P4128. 计数好题,原来是 13 年前就出现了经典套路啊.这题在当年应该很难吧. 题意简述: \(n\) 个点的完全图,点没有颜色,边有 \(m\) 种颜色,问本质不同的图的数量 ...
- ZeroMQ安装说明
ZeroMQ安装说明 1. 安装 1.1.Linux zmq安装 安装过程参考地址:http://zeromq.org/intro:get-the-software的说明 安装步骤如下(在安装时参 ...
- 苹果ANCS协议学习【转】
苹果ANCS协议学习 转自:http://www.cnblogs.com/alexcai/p/4321514.html 综述 苹果通知中心(Apple Notification Center Serv ...
- 高通Trustzone and QSEE介绍
http://blog.csdn.net/iamliuyanlei/article/details/52625968
- 【转】手把手教你 Mockito 的使用
原文链接:https://segmentfault.com/a/1190000006746409 什么是 Mockito Mockito 是一个强大的用于 Java 开发的模拟测试框架, 通过 Moc ...