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 ...
随机推荐
- Spring注解之@Lazy注解,源码分析和总结
一 关于延迟加载的问题,有次和大神讨论他会不会直接或间接影响其他类.spring的好处就是文档都在代码里,网上百度大多是无用功. 不如,直接看源码.所以把当时源码分析的思路丢上来一波. 二 源码分析 ...
- ace admin 左侧菜单定位
后台模版来自:Ace Admin http://ace.jeka.by/form-elements.html 左侧菜单,通过js根据url来判断显示哪块 window.location.pathnam ...
- 关于WebStorm,PhpStorm新版本输入中文问题
此文意在记录webstorm,PhpStorm输入中文无提示的问题,对于百忙中的开发无需浏览下面那一段套路话,直接浏览原文链接或者本博客绿色文字解决问题即可. 对于使用过dw,sublime,brac ...
- Teradata 认证系列 - 3. 关系型数据库的概念
本课的学习目标 定义关系型数据库关联的术语 讨论主键的功能 讨论外键的功能 列出关系型数据库的优势 描述星型架构和第三范式数据模型的区别 什么是数据库?数据库是一个应用永久保存数据的集合表现在: 逻辑 ...
- vue2.0 vue-cli+webpack使用less和scss的说明
config 目录下好像都不需要相关配置,但是package.json里面 使用less cnpm install --save-dev less less-loader //下面不需要配置,可省略 ...
- Android rxjava2的disposable
rxjava+retrofit处理网络请求 在使用rxjava+retrofit处理网络请求的时候,一般会采用对观察者进行封装,实现代码复用和拓展.可以参考我的这篇文章:rxjava2+retrofi ...
- Mysql数据库操作语句总结(一)
下面的内容来源于链接 https://www.cnblogs.com/bchjazh/p/5997728.html, 个人在此基础上进一步添加了一点东西. 个人操作数据库: mysql 5.5.2 ...
- SpringBoot的优缺点
优点: 1.快速构建项目 2.对主流开发框架的无配置继承 3.项目可独立运行,无须外部依赖Servlet容器 4.提高运行时的应用监控 5.极大地提高了开发.部署效率 6.与云计算的天然集成 缺点: ...
- WPF样式学习:ToolBar的使用
隐藏拖动把手: 设置ToolBar属性 ToolBarTray.IsLocked="True",可以达到隐藏拖动把手的目的 private void ToolBar_Loaded( ...
- LeetCode Longest Substring Without Repeating Characters 最长不重复子串
题意:给一字符串,求一个子串的长度,该子串满足所有字符都不重复.字符可能包含标点之类的,不仅仅是字母.按ASCII码算,就有2^8=128个. 思路:从左到右扫每个字符,判断该字符距离上一次出现的距离 ...