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;
}
总结:
方法很多,只是其中一种