pages:
  • 1
مصطفی SAYS

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package acm20142problembwebcolors; import java.util.Scanner; /** * * @author MOSTAFA */ public class Main {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    int[][] arr =
    {
                  { 255,255,255    },
                  { 192,192,192    },
                  { 128,128,128    },
                  { 0,0,0          },
                  { 255,0,0        },
                  { 128,0,0        },
                  { 255,255,0      },
                  { 128,128,0      },
                  { 0,255,0        },
                  { 0,128,0        },
                  { 0,255,255      },
                  { 0,128,128      },
                  { 0,0,255        },
                  { 0,0,128        },
                  { 255,0,255      },
                  { 128,0,128      }
    };
   // System.out.print(arr.length);
    String[] name_color={"White","Silver","Gray","Black","Red"," Maroon","Yellow","Olive","Lime","Green","Aqua","Teal","Blue","Navy","Fuchsia","Purple"};
    String s,r="";
    int a,b,c,k=0;
    double d,min=0;
    String[] str=new String[3];
    Scanner t=new Scanner(System.in);
    while(!((s=t.nextLine()).equals(  "-1 -1 -1")))
    {
    str=s.split(" ");
    a = Integer.parseInt(str[0]);
    b = Integer.parseInt(str[1]);
    c = Integer.parseInt(str[2]);

    for(int i=0;i<16;++i)
    {
        d=Math.sqrt(((Math.pow(arr[i][0]-a,2))+(Math.pow(arr[i][1]-b,2))+(Math.pow(arr[i][2]-c,2))))  ;
       if(i==0)      {min=d;k=i;}
       else if(min>d){min=d;k=i;}
    }
    r+=name_color[k]+"\n";
    }
    System.out.printf(r);

   // System.out.println(arr[6][1]);
}

}