Imp likes his plush toy a lot.
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 original toys? 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.
题意:原版的数目为A,复制品的数目为B。
1个A经过一次复制得到1个A和1个B
1个B经过一次复制得到2个B
给你B和A,问你能否得到这个数目的A和B
解题思路:在小本本上画画可以得出一个规律:B-(A-1)必为偶数(那个1就是一开始的A)。
还有几个必要的限制条件:
1.A必须大于等于1
2.B-(A-1)必须大于零
3.A为1时B必为0
AC代码:
#include<stdio.h>
int main()
{
int a,b;
while(~scanf("%d%d",&b,&a))
{
if(a==0||a==1&&b!=0) {printf("No\n");continue;}
int t=b-(a-1);
if(t%2!=0||t<0) printf("No\n");
else printf("Yes\n");
}
return 0;
}