print1615. Color sorting

printColor sorting

Ограничения: время – 1s/2s, память – 32MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

A hex triplet is a six-digit, three-byte hexadecimal number used in HTML, CSS, SVG, and other computing applications, to represent colors. The bytes represent the red, green and blue components of a color. One byte represents a number in the range 00 to FF in hexadecimal notation, or 0 to 255 in decimal notation. This represents the least (0) to the most (255) intensity of each of the color components. For example, black is represented by 000000 (no red, green or blue), white is represented by FFFFFF (red, green and blue at maximum intensity), and yellow is represented by FFFF00 (red and green at maximum intensity, no blue).
One way to measure the brightness of a color is to view it as a point in three-dimensional space with red, green, and blue axes, and measure its Euclidean distance from the origin (0,0,0) (i.e. black). By this measure, white is the brightest color. In this problem, you are given a list of hex triplets representing colors, and will sort them from brightest to darkest, i.e. fading to black.
Input
Each input line contains a hex triplet representing a color. Input file contains from 1 to 500 lines.
Output
Output the original lines of input, sorted so the colors appear by descending brightness. If two or more colors have equal brightness, they should appear in ascending alphabetical order.

Sample Input

003300
3AB2D7
56428D
FFFFFF
42568D
112200

Sample Output

FFFFFF
3AB2D7
42568D
56428D
003300
112200
Source: Computer Science Society programming contest, Fall 2010
loading