您的位置:首页 > 其它

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 2
Output
Yes
Input
5 6 1
2 7 2
Output
No
Input
3 3 3
2 2 2
Output
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]

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: