Description
Input
Output
Sample Input
Sample Output
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<algorithm> 6 #include<vector> 7 #define M(a,b) memset(a,b,sizeof(a)) 8 #include<map> 9 using namespace std; 10 11 long long R,Y,B; 12 13 int main() 14 { 15 while(scanf("%I64d%I64d%I64d",&R,&Y,&B)==3) 16 { 17 long long ans = 0; 18 if(R>=2&&Y>=2&&B>=2) //全大于1 19 ans = (R+Y+B-6)*6+15; 20 else 21 { 22 if(R==1&&Y>1&&B>1||Y==1&&R>1&&B>1||B==1&&Y>1&&R>1) //一个1其余大于1 23 { 24 ans = (R+Y+B-5)*5+10; 25 } 26 else if(R==1&&Y==1&&B>1||B==1&&Y==1&&R>1||R==1&&B==1&&Y>1) //两个1一个大于1 27 { 28 ans = (R+Y+B-4)*4+6; 29 } 30 else if(R==1&&Y==1&&B==1) //3个1 31 { 32 ans = 3; 33 } 34 else if(R==0&&Y>1&&B>1||B==0&&Y>1&&R>1||Y==0&&B>1&&R>1) //1个0 35 { 36 ans = (R+Y+B-4)*4+6; 37 } 38 else if(R==0&&Y==0&&B>1||B==0&&Y==0&&R>1||R==0&&B==0&&Y>1)//2个0 39 { 40 ans = (R+B+Y-2)*2+1; 41 } 42 else if(R==0&&Y==1&&B>1||R==1&&Y==0&&B>1||B==1&&Y==0&&R>1||B==0&&Y==1&&R>1||R==0&&B==1&&Y>1||B==0&&R==1&&Y>1) //1个0,1个1 43 { 44 ans = (R+B+Y-3)*3+3; 45 } 46 else if(R==0&&Y==1&&B==1||B==0&&Y==1&&R==1||Y==0&&B==1&&R==1)//1个0,2个1 47 { 48 ans = 1; 49 } 50 else ans = 0; //2个0,1个1,3个0 51 } 52 printf("%I64d\n",ans); 53 } 54 return 0; 55 }
原文:http://www.cnblogs.com/haohaooo/p/4018056.html