zoukankan      html  css  js  c++  java
  • Codeforces Round #461 (Div. 2) A. Cloning Toys

    A. Cloning Toys

    time limit per test 1 second
    memory limit per test 256 megabytes

    Problem Description

    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.


    解题心得:

    1. 比赛的时候差点被这个题的题意给绕进去,看了好久,其实这个题的意思是,
      • 你将一个原版的物品放入copy机,可以多得到一个原版的物品,多得到一个复制的物品。
      • 如果把复制的物品放入copy机,可以多得到两个复制的物品。
    2. 判定是否可以出现x个复制物品,y个原版的物品就很简单了。x-y+1必须是一个偶数,x-y+1必须大于等于零,y必须大于1(不能丢弃),y等于1的时候x必须等于0。判断不完全可能被hack。

    #include <bits/stdc++.h>
    using namespace std;
    const int maxn = 10;
    int main(){
        int a,b;
        scanf("%d%d",&a,&b);
        if((b == 1 && a != 0) || b == 0){
            printf("No
    ");
            return 0;
        }
        int c = a-b+1;
        if(c%2 || c < 0)
            printf("No
    ");
        else
            printf("Yes
    ");
        return 0;
    }
  • 相关阅读:
    Java入门3.2---线程池
    Java入门3.1---多线程
    打开ppt报"powerpoint无法加载mathtype加载项"错误
    LATEX排版总结
    casbin 权限系统
    Go netpoll I/O 多路复用构建原生网络模型之源码深度解析
    使用winsw包装服务将nginx包装为Windows服务
    Node.js 的模块系统
    一文读懂 babel7 的配置文件加载逻辑
    vue-cli是什么?和 webpack是什么关系?
  • 原文地址:https://www.cnblogs.com/GoldenFingers/p/9107178.html
Copyright © 2011-2022 走看看