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.
解题心得:
- 比赛的时候差点被这个题的题意给绕进去,看了好久,其实这个题的意思是,
- 你将一个原版的物品放入copy机,可以多得到一个原版的物品,多得到一个复制的物品。
- 如果把复制的物品放入copy机,可以多得到两个复制的物品。
- 判定是否可以出现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\n");
return 0;
}
int c = a-b+1;
if(c%2 || c < 0)
printf("No\n");
else
printf("Yes\n");
return 0;
}
Codeforces Round #461 (Div. 2) A. Cloning Toys的更多相关文章
- CF922 CodeForces Round #461(Div.2)
CF922 CodeForces Round #461(Div.2) 这场比赛很晚呀 果断滚去睡了 现在来做一下 A CF922 A 翻译: 一开始有一个初始版本的玩具 每次有两种操作: 放一个初始版 ...
- Codeforces Round #461 (Div. 2)
A - Cloning Toys /* 题目大意:给出两种机器,一种能将一种原件copy出额外一种原件和一个附件, 另一种可以把一种附件copy出额外两种附件,给你一个原件, 问能否恰好变出题目要求数 ...
- Codeforces Round #461 (Div. 2) B C D
题目链接:http://codeforces.com/contest/922 B. Magic Forest time limit per test 1 second memory limit per ...
- Codeforces Round #461 (Div. 2) D. Robot Vacuum Cleaner
D. Robot Vacuum Cleaner time limit per test 1 second memory limit per test 256 megabytes Problem Des ...
- Codeforces Round #461 (Div. 2) C. Cave Painting
C. Cave Painting time limit per test 1 second memory limit per test 256 megabytes Problem Descriptio ...
- Codeforces Round #461 (Div. 2) B. Magic Forest
B. Magic Forest time limit per test 1 second memory limit per test 256 megabytes Problem Description ...
- Codeforces Round #461 (Div. 2)B-Magic Forest+位运算或优雅的暴力
Magic Forest 题意:就是在1 ~ n中找三个值,满足三角形的要求,同时三个数的异或运算还要为0: , where denotes the bitwise xor of integers ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
随机推荐
- 前端专业术语: shim 和 Polyfill,了解下
在学习和使用 JavaScript 的时候,我们会经常碰到两个术语:shim 和 polyfill.它们有许多定义和解释,意思相近又有差异. Shim Shim 指的是在一个旧的环境中模拟出一个新 A ...
- 斐波那契数列【java实现】
java 实现斐波那契数列 以下是Java代码实现(递归与递推两种方式): import java.util.Scanner; /** * Fibonacci * * @author tongqian ...
- 给类型为text的input设置value值却无法修改
给类型为text的input设置value值后就无法修改了 我的页面显示为如下但是退格却无法改变他的值 原来是缺少onChange事件,没法监听value的改变 所以需要添加 onChange={th ...
- GreenDao 使用知识小y
//关于 group by 的实现//--------------------XXXDao.queryBuilder().where(new WhereCondition.StringConditio ...
- Python开发环境Wing IDE搜索工具介绍
Wing IDE编辑器的搜索工具提供了一个基于友好GUI的搜索和替换工具. 某些情况下搜索可能会跨越整个文件,也有可能被限制到当前所选择的区域:可以区分大小写,也可以设置为不区分:可以被限制为只匹配整 ...
- HDU4417 线段树 + 离线处理
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4417 , 线段树(或树状数组) + 离线处理 最近看了几道线段树的题都是需要离线处理数据的,正好这块比 ...
- linux 命令——55 traceroute(转)
通过traceroute我们可以知道信息从你的计算机到互联网另一端的主机是走的什么路径.当然每次数据包由某一同样的出发点(source)到达某一同样的目的地(destination)走的路径可能会不一 ...
- SAP成都研究院马洪波:提升学习力,增强竞争力,收获一生乐趣
马洪波是SAP成都研究院CEC开发团队三大巨头之一.关于他的背景介绍,参考我以前的公众号文章:SAP成都研究院CEC团队三巨头之一:M君的文章预告. 其实早在2007年,互联网上已经有介绍马洪波的文章 ...
- JavaScript:理解worker事件api
如果你不是很了解Event事件,建议先看我上一篇随文javascript:理解DOM事件.或者直接看下文worker api. hack 首先,我们需要实例一个Worker的对象,浏览器会根据新创建的 ...
- 【洛谷4424】[HNOI/AHOI2018] 寻宝游戏(位运算思维题)
点此看题面 大致题意: 给你\(n\)个\(m\)位二进制数.每组询问给你一个\(m\)位二进制数,要求你从\(0\)开始,依次对于这\(n\)个数进行\(and\)或\(or\)操作,问有多少种方案 ...