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.
这个·题目很有趣啊,找规律 啊
#include<iostream> using namespace std; int main(){ int x,y; int t ; while(cin>>x>>y) { if(y==0|| y==1&&x>0) cout<<"No"<<endl; else { int t =y-1; if((x-t)%2==0&&x-t>=0) cout<<"Yes"<<endl; else cout<<"No"<<endl; } } }
未来的我一定会感谢正在努力的现在的我!
本文探讨了一个关于玩具克隆机的问题,通过分析如何使用该机器来获得特定数量的原版和复制玩具,提出了一种解决策略。文章提供了一个简单的C++程序实现,用于判断是否能达成目标配置。
544

被折叠的 条评论
为什么被折叠?



