AtCoder题解——Beginner Contest 170——B - Crane and Turtle

题目相关

题目链接

AtCoder Beginner Contest 170 B题,https://atcoder.jp/contests/abc170/tasks/abc170_b。

Problem Statement

There are some animals in a garden. Each of them is a crane with two legs or a turtle with four legs.

Takahashi says: "there are X animals in total in the garden, and they have Y legs in total." Determine whether there is a combination of numbers of cranes and turtles in which this statement is correct.

Input

Input is given from Standard Input in the following format:

X Y

Output

If there is a combination of numbers of cranes and turtles in which the statement is correct, print Yes; otherwise, print No.

Samples1

Sample Input 1

3 8

Sample Output 1

Yes

Explaination

The statement "there are 3 animals in total in the garden, and they have 8 legs in total" is correct if there are two cranes and one turtle. Thus, there is a combination of numbers of cranes and turtles in which the statement is correct.

Samples2

Sample Input 2

2 100

Sample Output 2

No

Explaination

There is no combination of numbers of cranes and turtles in which this statement is correct.

Samples3

Sample Input 3

1 2

Sample Output 2

Yes

Explaination

We also consider the case in which there are only cranes or only turtles.

Constraints

  • 1 ≤ X ≤ 100
  • 1 ≤ Y ≤ 100
  • All values in input are integers.

题解报告

题目翻译

其实就是鸡兔同笼问题啦。

在院子里有鹤和乌龟,每个鹤有两条腿,每个乌龟有四条腿。然后告诉我们 X 个动物,Y 条腿。问这样的组合是否合法。如果合法输出 Yes,如果不合法,输出 No。

样例数据分析

略。

题目分析

可以直接解方程,然后判断合法性。

也可以直接判断合法性。

数据规模分析

100 以内的数据,没有什么难度。

AC 参考代码

略。

P.S.

水一篇文章吧。

 

你可能感兴趣的:(OJ题解,#,AtCoder题解,AtCoder题解,ABC,170,B题)