zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    布署脚本
    HTTP请求报文支持的各种方法
    robot framework学习笔记之六—自动变量
    robot framework接口测试之二-四种常见的POST提交数据方式
    自定义过滤器-时间转化器
    自定义过滤器-有参数
    自定义过滤器-没有参数
    过滤器-orderBy
    过滤器-limitBy
    过滤器-filterBy
  • 原文地址:https://www.cnblogs.com/qscqesze/p/6359964.html
Copyright © 2011-2022 走看看