水~
View Code
1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #include<algorithm> 5 #include<map> 6 using namespace std; 7 int in[ 10 ],sum[ 8 ]; 8 /* 9 BCG 1 2 3//(12)(34)(68) 10 BGC 1 3 2//(12)(35)(67) 11 12 CBG 2 1 3//(01)(45)(68) 13 CGB 2 3 1//(01)(35)(78) 14 15 GBC 3 1 2//(02)(45)(67) 16 GCB 3 2 1//(02)(34)(78) 17 input:BGC 18 */ 19 20 int main(){ 21 while( scanf("%d%d%d%d%d%d%d%d%d",&in[ 0 ],&in[ 1 ],&in[ 2 ],&in[ 3 ],&in[ 4 ],&in[ 5 ],&in[ 6 ],&in[ 7 ],&in[ 8 ])==9 ){ 22 int flag,Min; 23 Min=999999; 24 sum[ 1 ]=in[1]+in[2]+in[3]+in[4]+in[6]+in[8]; 25 sum[ 2 ]=in[1]+in[2]+in[3]+in[5]+in[6]+in[7]; 26 sum[ 3 ]=in[0]+in[1]+in[4]+in[5]+in[6]+in[8]; 27 sum[ 4 ]=in[0]+in[1]+in[3]+in[5]+in[7]+in[8]; 28 sum[ 5 ]=in[0]+in[2]+in[4]+in[5]+in[6]+in[7]; 29 sum[ 6 ]=in[0]+in[2]+in[3]+in[4]+in[7]+in[8]; 30 for( int i=1;i<=6;i++ ) 31 if( Min>sum[ i ] ){ 32 Min=sum[ i ]; 33 flag=i; 34 } 35 if( flag==1 ) 36 printf("BCG %d\n",sum[flag]); 37 else if( flag==2 ) 38 printf("BGC %d\n",sum[flag]); 39 else if( flag==3 ) 40 printf("CBG %d\n",sum[flag]); 41 else if( flag==4 ) 42 printf("CGB %d\n",sum[flag]); 43 else if( flag==5 ) 44 printf("GBC %d\n",sum[flag]); 45 else if( flag==6 ) 46 printf("GCB %d\n",sum[flag]); 47 } 48 return 0; 49 }