CodeForces 606 A. Magic Spheres(水~)
2016-02-29 22:13
246 查看
Description
一个人有a个蓝色,b个紫色,c个橘色的魔法球,他每次可以用两个相同颜色的球变出一个任意颜色的球,这个人需要x个蓝色,y个紫色,z个橘色的球,问已有的球能否满足条件
Input
六个整数a,b,c,x,y,z(0<=a,b,c,x,y,z<=1000000)
Output
如果已有的球可以满足条件则输出Yes,否则输出No
Sample Input
4 4 0
2 1 2
Sample Output
Yes
Solution
水题,比较多出的球的一半与少的球的数量即可
Code
一个人有a个蓝色,b个紫色,c个橘色的魔法球,他每次可以用两个相同颜色的球变出一个任意颜色的球,这个人需要x个蓝色,y个紫色,z个橘色的球,问已有的球能否满足条件
Input
六个整数a,b,c,x,y,z(0<=a,b,c,x,y,z<=1000000)
Output
如果已有的球可以满足条件则输出Yes,否则输出No
Sample Input
4 4 0
2 1 2
Sample Output
Yes
Solution
水题,比较多出的球的一半与少的球的数量即可
Code
#include<cstdio> #include<iostream> using namespace std; int a,b,c,x,y,z; int main() { while(~scanf("%d%d%d%d%d%d",&a,&b,&c,&x,&y,&z)) { int res1=0,res2=0; if(a>x)res1+=(a-x)/2; else res2+=x-a; if(b>y)res1+=(b-y)/2; else res2+=y-b; if(c>z)res1+=(c-z)/2; else res2+=z-c; if(res1>=res2)printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- Vijos P1123均分纸牌
- 项目记录24--unity-tolua框架 View01---UIBase.lua
- Ubuntu设置ssh免密码登陆
- WEB开发者必备的7个JavaScript函数
- 快速制作网页的方法
- poj--1274--The Perfect Stall(匈牙利裸题)
- 多个无线路由器的文件及打印共享
- C++学习笔记52——继承情况下类的作用域
- 表单
- poj--1274--The Perfect Stall(匈牙利裸题)
- 大型网站的灵魂——性能
- 常用Linux命令
- C#本质论 读书 笔记(五)
- JAVA并发编程-线程间协作(Object监视器方法与Condition)
- 解决“无法完成操作,因为文件包含病毒或潜在的垃圾软件”
- 隐藏输入法
- hdu3652
- poj3159Candies——差分约束系统
- (广度优先搜索第一课)迷宫的最短路径 - BFS
- SSH进阶——Struts入门