codeforce 606A - Magic Spheres
题意:a,b,c三种球,能把俩个一样的球变成另一颜色不一样的球。给你目标x,y,z,问能否经过变化至少达打目标。
1 #include<iostream> 2 #include<stdio.h> 3 #include<stdlib.h> 4 #include<memory.h> 5 #include<string.h> 6 #include<algorithm> 7 #include<cmath> 8 const int N = 30; 9 const int inf=-100000; 10 using namespace std; 11 int ans; 12 void fun(int x) 13 { 14 if(x>=0) 15 { 16 ans+=x/2; 17 } 18 else 19 { 20 ans+=x; 21 } 22 } 23 24 int main() 25 { 26 int a[3]; 27 int b[3]; 28 while(~scanf("%d%d%d",&a[0],&a[1],&a[2])) 29 { 30 scanf("%d%d%d",&b[0],&b[1],&b[2]); 31 ans=0; 32 fun(a[0]-b[0]); 33 //cout<<ans<<endl; 34 fun(a[1]-b[1]); 35 //cout<<ans<<endl; 36 fun(a[2]-b[2]); 37 //cout<<ans<<endl; 38 if(ans>=0) 39 { 40 cout<<"Yes"<<endl; 41 } 42 else 43 { 44 cout<<"No"<<endl; 45 } 46 } 47 return 0; 48 }