(UVA)102-回收桶


#include<stdio.h>

int main()

{

  long   B[3], G[3], C[3], temp[6], i, j;



  while (scanf("%ld %ld %ld %ld %ld %ld %ld %ld %ld", &B[0], &G[0], &C[0], &B[1], &G[1], &C[1], &B[2], &G[2], &C[2]) != EOF){

  long  total=0;

  long  min ;



  total = B[0] + G[0] + C[0] + B[1] + G[1] + C[1] + B[2] + G[2] + C[2];



  min = total;



  temp[0] = total - B[0] - C[1] - G[2];       /*BCG*/



  temp[1] = total - B[0] - G[1] - C[2];     /*BGC*/



  temp[2] =   total - C[0] - B[1] - G[2]; /*CGB*/



  temp[3] =    total - C[0] - G[1] - B[2];    /*CBG*/



  temp[4] = total - G[0] - B[1] - C[2];    /*GBC*/



  temp[5] = total - G[0] - C[1] - B[2];    /*GCB*/





  for (i = 0; i < 6; i++)/*最小移動數*/

  {

   if (temp[i] < min)

   {

   min = temp[i];

   j = i;

   }

  }

 

   if (j == 0) printf("BCG %ld\n",min);

   else if (j == 1) printf("BGC %ld\n",min);

   else if (j == 3) printf("CGB %ld\n",min);

   else if (j == 2) printf("CBG %ld\n",min);

   else if (j == 4) printf("GBC %ld\n",min);

   else if (j == 5) printf("GCB %ld\n",min);

 

  }

  return 0;

 }

留言

這個網誌中的熱門文章

Bundle Adjustment 光束平差法

Structure From Motion