zoukankan      html  css  js  c++  java
  • CF922A Cloning Toys

    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.

    有两种玩具,这里假设成A、B两种玩具,A玩具可以再产生一个A玩具和一个B玩具,B玩具可以再产生两个B玩具。现在我们有一个A玩具,问最后是否能得到X个B玩具,Y个A玩具。能得到输出Yes,不能得到输出No。

    #include<map>
    #include<queue>
    #include<cstdio>
    #include<cstdlib>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #define maxn 100010
    #define debug(a) cout << #a << " " << a << endl
    using namespace std;
    typedef long long ll;
    int main() {
        int n,m;
        while( cin >> n >> m ) {
            if( n == 0 && m == 1 ) {
                cout << "Yes" << endl;
                continue;
            }
            if( n == 0 || m == 1 || m == 0 ) {
                cout << "No" << endl;
                continue;
            }
            if( ( n - m + 1 ) % 2 == 0 && ( n - m + 1 ) >= 0 ) {
                cout << "Yes" << endl;   //注意负的偶数余2也等于0,这里要特判下,因为没有考虑到这种情况WA两次。。。
            } else {
                cout << "No" << endl;
            }
        }
        return 0;
    }
    彼时当年少,莫负好时光。
  • 相关阅读:
    Xilinx之软件平台 ISE与Vivado前世今生
    博客开园
    第一天:开始你的Jobeet项目
    MySQL之alter语句用法总结
    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
    MySQL中distinct和group by性能比较[转]
    GROUP BY,WHERE,HAVING之间的区别和用法
    split(),preg_split()与explode()函数分析与介
    解析posix与perl标准的正则表达式区别
    sql关键字的解释执行顺序
  • 原文地址:https://www.cnblogs.com/l609929321/p/8443142.html
Copyright © 2011-2022 走看看