标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 868 Accepted Submission(s): 392
#include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #define LL long long using namespace std; int main() { int tcase,t = 1; scanf("%d",&tcase); while(tcase--) { int x,y,z; scanf("%d%d%d",&x,&y,&z); int ans = 0,a,b,c; if(x>=2&&y>=1){ /// 20 20 28 a = x/2,b=y; c = min(a,b); x=x-2*c,y=y-c; ans+=c; } if(x>=2&&z>=1){ ///20 20 32 a = x/2,b = z; c = min(a,b); x=x-2*c,z=z-c; ans+=c; } if(x>=3){ ///20 20 20 a = x/3; x = x%3; ans+=a; } if(y>=1&&z>=1){ ///28 32 c = min(y,z); ans+=c; y-=c; z-=c; } if(y>=2){ ///28 28 c = y/2; y = y%2; ans+=c; } if(z>=2){///32 32 c = z/2; z = z%2; ans+=c; } if(x||y||z) ans++; printf("Case %d: %d\n",t++,ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5917865.html