Imp likes his plush toy a lot.
![](https://i-blog.csdnimg.cn/blog_migrate/629bbfb475c98a527a3dcda73f480589.png)
Recently, he found a machine that can clone plush toys. Imp knows that if he applies the machine to an original toy, he additionally gets one more original toy and one copy, and if he applies the machine to a copied toy, he gets two additional copies.
Initially, Imp has only one original toy. He wants to know if it is possible to use machine to get exactly x copied toys and y originaltoys? He can't throw toys away, and he can't apply the machine to a copy if he doesn't currently have any copies.
The only line contains two integers x and y (0 ≤ x, y ≤ 109) — the number of copies and the number of original toys Imp wants to get (including the initial one).
Print "Yes", if the desired configuration is possible, and "No" otherwise.
You can print each letter in arbitrary case (upper or lower).
6 3
Yes
4 2
No
1000 1001
Yes
In the first example, Imp has to apply the machine twice to original toys and then twice to copies.
题意:有一种机器,可以将一个原生玩具变为2个原生玩具和1个复制,或将一个复制变为3个复制。初始只有1个原生玩具。现在给出x和y,求是否可以恰好变出x个复制与y个原生玩具。
将可能的复制情况列出来即可找到规律。不过要注意y=0或y=1时的坑点。
原生玩具数 可能的复制数
1 0
2 1,3,5...
3 2,4,6...
4 3,5,7...
代码如下:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
while (~scanf("%d %d",&n,&m)){
if (n==m-1){
printf("yes\n");
continue;
}
else if (n<m||m==0||(m==1&&n>0)){
printf("no\n");
continue;
}
int f=(n-m-1)%2;
if (!f){
printf("yes\n");
continue;
}
else{
printf("no\n");
continue;
}
}
return 0;
}