CodeForces 606 A. Magic Spheres(水~)

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

#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;
}

你可能感兴趣的:(CodeForces 606 A. Magic Spheres(水~))