• Codeforces Round #461 (Div. 2) A. 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.

     这题是找规律的题,不过有坑点,需要考虑y=1,x只能=0,以及y=0的情况不存在

    代码如下:

    #include<stdio.h>
    int main()
    {
    int x,y;
    while(~scanf("%d %d",&x,&y))
    {
    if(y==1&&x>0||y==0)
    printf("No ");
    else
    {
    int t=y-1;
    if((x-t)%2==0&&x-t>=0)
    {
    printf("Yes ");
    }
    else
    printf("No ");
    }
    }

    return 0;
    }

     刚开始读题,就凭借自己的主观印象觉得x,y是谁,结果分析样例怎么都分析不对.......

    以后读题一定要仔细看每一个变量分别代表的是谁......

    最开始想的这个规律有一点漏洞,那就是没考虑到对于每一个y,x都有一个最小值,如果数据比这个值小的话,也是不行的(刚才手滑,不小心把键盘弄掉了,现在回来继续.....)

    推规律的时候耐心一点,不然交上去也是wa

  • 相关阅读:
    C# String.Format用法和格式说明
    VS2017桌面应用程序打包成.msi或者.exe
    Mysql授权允许远程访问
    C# Winform频繁刷新导致界面闪烁解决方法
    C# 解决窗体闪烁
    C# winform或控制台Properties.Settings.Default的使用及存储位置
    C# 获取计算机cpu,硬盘,内存相关的信息
    C# 多线程多文件批量下载---子线程中更新UI 实例
    Objective-C:NSSet和NSMutbaleSet的用法
    iOS:App上架流程和支付宝支付流程
  • 原文地址:https://www.cnblogs.com/renxin123/p/8432157.html
Copyright © 2020-2023  润新知