A - Edge Checker

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

Problem Statement

In the figure shown in the image below, are the points numbered aa and bb directly connected by a line segment?

Constraints

  • 1 \leq a \lt b \leq 101≤a<b≤10
  • aa and bb are integers.

Input

Input is given from Standard Input in the following format:

aa bb

Output

If the points numbered aa and bb are directly connected by a line segment, print Yes; otherwise, print No.
The judge is case-sensitive: be sure to print uppercase and lowercase letters correctly.


Sample Input 1 Copy

Copy

4 5

Sample Output 1 Copy

Copy

Yes

In the figure shown in the Problem Statement, the points numbered 44 and 55 are directly connected by a line segment.
Thus, Yes should be printed.


Sample Input 2 Copy

Copy

3 5

Sample Output 2 Copy

Copy

No

In the figure shown in the Problem Statement, the points numbered 33 and 55 are not directly connected by a line segment.
Thus, No should be printed.


Sample Input 3 Copy

Copy

1 10

Sample Output 3 Copy

Copy

Yes

 题目大意:

不要被图片迷惑,其实很简单的。就是从1到10只要是连续的两个数就输出“Yes"反之就输出"No",很简单吧?但是!有个特判10和1也是符合的,别问为i啥,因为图片上10和1是相邻的。

思路:

上代码

坑点:

看清”Yes"是首字母才大写的

代码:

#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
const int N=200005;
int a[N];
int main()
{
    int a,b;cin>>a>>b;//输入输出就不说了 
    if(a==1&&b==10||a==10&&b==1)//特判 
    {
        cout<<"Yes";
        return 0;
    }
    if(abs(a-b)==1)//其实就是两个数的绝对值是1就行 
    {
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}
 

总结:

方法很多,只是其中一种

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值