Color Me Less
Color Me Less
Time Limit: 2 Seconds Memory Limit: 65536 KB
Problem
A color reduction is a mapping from a set of discrete colors to a smaller one. The solution to this problem requires that you perform just such a mapping in a standard twenty-four bit RGB color space. The input consists of a target set of sixteen RGB color values, and a collection of arbitrary RGB colors to be mapped to their closest color in the target set. For our purposes, an RGB color is defined as an ordered triple (R,G,B) where each value of the triple is an integer from 0 to 255. The distance between two colors is defined as the Euclidean distance between two three-dimensional points. That is, given two colors (R1,G1,B1) and (R2,G2,B2), their distance D is given by the equation

#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std; int main()
{
int r[], b[], g[];
for(int i = ; i < ; i++)
{
scanf("%d %d %d", r + i, g + i, b + i);
}
int x, y, z;
while(scanf("%d %d %d", &x, &y, &z))
{
if(x == - && y == - && z == -) break;
double minD = (x - r[]) * (x - r[]) + (y - g[])* (y - g[]) + (z - b[]) * (z - b[]);
int id = ;
for(int i = ; i < ; i++)
{
double D = (x - r[i]) * (x - r[i]) + (y - g[i]) * (y - g[i]) + (z - b[i]) * (z - b[i]);
if(minD > D)
{
minD = D;
id = i;
}
}
printf("(%d,%d,%d) maps to (%d,%d,%d)\n", x, y, z, r[id], g[id], b[id]);
// cout << id << endl;
}
return ;
}
Color Me Less的更多相关文章
- 【转】c#、wpf 字符串,color,brush之间的转换
转自:http://www.cnblogs.com/wj-love/archive/2012/09/14/2685281.html 1,将#3C3C3C 赋给background this.selec ...
- Python为8bit深度图像应用color map
图片中存在着色版的概念,二维矩阵的每个元素的值指定了一种颜色,因此可以显示出彩色. 迁移调色板 下述python代码将VOC数据集中的某个语义分割的图片的调色板直接应用在一个二维矩阵代表的图像上 #l ...
- (转)System.Drawing.Color的颜色对照表
经常使用System.Drawing.Color, 本篇介绍一下颜色与名称及RGB值的对应关系. 1. 颜色与名称的对照表(点击下图放大看): 2. 颜色与RGB值对照表: Color.AliceBl ...
- 激光打印机的Color/paper, Xerography介绍
Color Basic 看见色彩三要素: 光源,物体,视觉 加色色彩模型:R,G,B 多用于显示器 减色色彩模型:C,M,Y,K 多用于打印复印 Paper 东亚地区常用A系列标准用纸,在多功能一体机 ...
- 安卓工具箱:color of Style
<?xml version="1.0" encoding="utf-8"?> <resources> <color name=&q ...
- UITableView 一直显示滚动条(ScrollBar Indicators)、滚动条Width(宽度)、滚动条Color(颜色)
在 IOS 中,对 UIScrollView 的滚动条(ScrollBar Indicators)的自定义设置接口,一直都是很少的.除了能自定义简单的样式(UIScrollViewIndicatorS ...
- OpenCASCADE Color Scale
OpenCASCADE Color Scale eryar@163.com Abstract. The color scale is a specialized label object that d ...
- Color Transfer between Images code实现
上计算机视觉课老师布置的作业实现论文:Color Transfer between Images 基本思路是: 1.给定srcImg和targetImg 2.将RGB空间转为Lab空间 3.根据论文中 ...
- ZOJ Problem Set - 1067 Color Me Less
这道题目很简单,考察的就是结构体数组的应用,直接贴代码了 #include <stdio.h> #include <math.h> typedef struct color { ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
随机推荐
- 【转】关于KDD Cup '99 数据集的警告,希望从事相关工作的伙伴注意
Features From: Terry Brugger Date: 15 Sep 2007 Subject: KDD Cup '99 dataset (Network Intrusion) cons ...
- HTTP协议之chunk编码(分块传输编码
Transfer-Encoding: chunked 表示输出的内容长度不能确定,普通的静态页面.图片之类的基本上都用不到这个. 但动态页面就有可能会用到,但我也注意到大部分asp,php,asp.n ...
- JNI技术基础(2)——从零开始编写JNI代码
书接上文: <JNI技术基础(1)——从零开始编写JNI代码> 2.编译源程序HelloWorld.java并生成HelloWorld.class 3.生成头文件HelloWorld.h ...
- Asset Catalog Help (二)---Creating an Asset Catalog
Creating an Asset Catalog Create an asset catalog to simplify management of your app’s images. 创建一个a ...
- 编写西游记人物类(XiYouJiRenWu)
package java1; public class XiYouJiRenWu { double height; String name; String weapon; void printName ...
- 最近碰到了一个病毒木马:virus.win32.ramnit.B
由于 使用了 简单游 平台上的挂机工具: 番茄-自动人机对战免费版1217 ,使用了很久,头段时间家里电脑 360提示有病毒,本来我一直忽略的,但 我扫描了一下,大量的这个木马,于是 吧 简单游卸载 ...
- C#:注册机的实现【提供源代码下载】
代码下载 C#软件注册机 软件运行结果 参考文章 http://www.cnblogs.com/hanzhaoxin/archive/2013/01/04/2844191.html
- tomcat文件服务配置
<Host name="localhost" appBase="" unpackWARs="true" auto ...
- 只写104行代码!在nopCommerce中如何实现自动生成网站地图
表告诉我说你不知道nopCommerce是什么.它是目前.NET中最流行的完全开源网上商城,由俄罗斯的团队在2008年开始立项一直开发到现在已经是3.3版本了.代码目前托管在codeplex上,有兴趣 ...
- GTD时间管理(1)---捕获搜集
前一段时间感觉自己的整个思路很混乱,每一天觉得自己有很多事情很多,但是坐着做着不知道自己做了多少,做项目的时候做着做着时常东想西想.我个人觉得这种想法是不对经的. 于是在google上都出去寻找这方面 ...