Web Colors
Time Limit: 10 Seconds Memory Limit: 131072 KB
Web
colors are colors
used in displaying web pages. Each color
may be specified either as an RGB triple, or a common English name used for that color. Colors are specified according to the intensity of their red, green and blue components, each repre- sented by eight bits. Thus,
there are 24 bits used to specify a web color, and totally 16,777,216 colors can be imagined as web
colors. But the HTML 4 specification defines only 16 named colors as shown in the table.
It is often useful
to map one given color to one of the HTML named
colors. The goal of this problem is to perform just such a mapping
in the RGB color space. The input to the program consists of a collection of RGB color
values to be mapped to the
closest HTML named color.
For a given color,
the
“closest” color in the HTML color names is a color with the smallest Euclidean distance from the given color. That
is, if rgb is the color
to be mapped, and {R1 G1 B1 , . . . , R16 G16 B16 } is the set of the HTML colors, the closest color is the one which
minimizes the distance
expression
where i is an integer
from 1 to 16.
Input
There are multiple test cases in the input. Each test case consists
of a line containing three integers 0 ⩽ r, g, b ⩽ 255 which are the Red, Green and Blue intensities of the color, respectively. The input terminates with -1 -1 -1 which should not be processed.
Output
For
each test case, output a line containing the name of the closest
HTML color to the given color. If there are more than
one closest color, print the one which has a smaller
associated number in the above table.
Sample Input
120 120 10 111 112 113 5 135 8 -1 -1 -1
Sample Output
Olive Gray GreenSubmit
Source: Tehran, Asia Region - Regional 2014