Codeforces Round #461 (Div. 2) A. Cloning Toys(水题)

本文介绍了一个关于克隆玩具的问题,通过使用特定机器可以增加原版玩具和复制品的数量。文章详细阐述了如何判断能否得到指定数量的原版玩具和复制品,并提供了具体的算法实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Cloning Toys
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.
Input

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).
Output

Print “Yes”, if the desired configuration is possible, and “No” otherwise.

You can print each letter in arbitrary case (upper or lower).
Examples
Input

6 3

Output

Yes

Input

4 2

Output

No

Input

1000 1001

Output

Yes

Note

In the first example, Imp has to apply the machine twice to original toys and then twice to copies.

这题虽然不难,但是有很多细节需要考虑到,代码中会体现

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 0x3f3f3f3f
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i>=b;i--)
#define rson rt<<1|1,m+1,r
#define lson rt<<1,l,m
using namespace std;
const int N=1e5;
int arr[N];
int main()
{
    ios::sync_with_stdio(false);
    int x,y;
    cin>>y>>x;
    if(x==1&&y>0||x==0)
    {
        cout<<"No"<<endl;
        return 0;
    }
    int c=x-1;
    y-=c;
    if(y>=0&&y%2==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值