CodeForces 606A-A. Magic Spheres【模拟】
2016-01-13 10:24
204 查看
A. Magic Spherestime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputCarl is a beginner magician. He has a blue,b violet and c orange magic spheres. In one move he can transform two spheresof the same color into one sphere of any other color. To make a spell that has never been seen before, he needs at leastx blue, y violet andz orange spheres. Can he get them (possible, in multiple actions)?InputThe first line of the input contains three integers a,b and c (0 ≤ a, b, c ≤ 1 000 000) — the number of blue, violet and orange spheres that are in the magician's disposal.The second line of the input contains three integers, x,y and z (0 ≤ x, y, z ≤ 1 000 000) — the number of blue, violet and orange spheres that he needs to get.OutputIf the wizard is able to obtain the required numbers of spheres, print "Yes". Otherwise, print "No".Sample test(s)Input
4 4 0 2 1 2Output
YesInput
5 6 1 2 7 2Output
NoInput
3 3 3 2 2 2Output
Yes
题目大意:
题目大意就是上面一行是现有的球下面一行是需要的球,魔法师可以将两个相同颜色的球变成另外颜色的球,问是否可以做到。
#include<stdio.h> #include<cmath> #include<string.h> int main() { int a,b,c,x,y,z; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { scanf("%d%d%d",&x,&y,&z); int qx=0,qy=0,qz=0; qx=a-x; qy=b-y; qz=c-z; int lx=0,ly=0,lz=0; if(qx>0) lx=qx/2; if(qy>0) ly=qy/2; if(qz>0) lz=qz/2; lx+=ly+lz; int zz=0; if(qx<0) zz+=qx; if(qy<0) zz+=qy; if(qz<0) zz+=qz; zz*=-1; if(lx>=zz) printf("Yes\n"); else printf("No\n"); } return 0; }[/code]
相关文章推荐
- java发邮件(1)
- TCP连接的建立(二)
- JAVA线程同步辅助类Exchanger-交换
- 对一个多态例题学习的一些思考
- cocos2d-x 卓上改变工程图标的步骤
- 用消息队列和消息应用状态表来消除分布式事务
- 免费午餐已结束:并发成为软件的基本转向
- UICollectionView
- MFC学习(22)MFC常用类:CFile文件操作类
- Jenkins学习笔记(一)
- Gradle for Android
- [FAQ17469]打开自动调节背光功能后,手动调节背光到最小,屏幕完全变黑
- NSUserDefaults  的用法
- gstreamer 捕获图像+存储示例代码
- 最近碰到了一个病毒木马:virus.win32.ramnit.B
- 自动刷闪存脚本闪存
- iOS开发 关于iBeacon的一些记录
- Lua 5.1 参考手册
- [java] java 设计模式(2):抽象工厂模式(Abstract Factory)
- 水平进度条ProgressBar(progressBarStyleHorizontal)