2023.7.8Atcoder309 A题

Problem Statement

We have the following 3 × 3 3 \times 3 3×3 board with integers from 1 1 1 through 9 9 9 written on it.
You are given two integers A A A and B B B between 1 1 1 and 9 9 9, where A < B A < B A<B.
Determine if the two squares with A A A and B B B written on them are adjacent horizontally.

Constraints

  • 1 ≤ A < B ≤ 9 1 \le A < B \le 9 1A<B9
  • A A A and B B B are integers.

Input

The input is given from Standard Input in the following format:

A B

Output

Print Yes if the two squares with A A A and B B B written on them are adjacent horizontally, and No otherwise.

Sample 1

InputOutput
7 8Yes

The two squares with 7 7 7 and 8 8 8 written on them are adjacent horizontally, so print Yes.

Sample 2

InputOutput
1 9No

Sample 3

InputOutput
3 4No

题意

在一块 3 × 3 3 \times 3 3×3 的板上有整数 1 − 9 1-9 19。给定两个数 A , B A,B A,B A , B A,B A,B 1 − 9 1-9 19之间,且 A < B A < B A<B。判断 A , B A,B A,B 是否相邻。

分析

相邻是指 A , B A,B A,B在同一行,并且 A = B − 1 A = B - 1 A=B1。因为 A A A B B B 小,所以如果 A A A 在第3列的话(也就是 A % 3 = = 0 A \% 3 == 0 A%3==0), A , B A,B A,B 就在上下两行,不符合规定。
程序用if语句判断一下就行了。

代码

#include <bits/stdc++.h>
using namespace std;

int a, b;

int main(){
	cin >> a >> b;
	if (a == b - 1 && a % 3 != 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值