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很想,计算这 ...
随机推荐
- HTTP协议之chunk编码(分块传输编码
Transfer-Encoding: chunked 表示输出的内容长度不能确定,普通的静态页面.图片之类的基本上都用不到这个. 但动态页面就有可能会用到,但我也注意到大部分asp,php,asp.n ...
- Atitit..文件上传组件选型and最佳实践总结(2)----断点续传
Atitit..文件上传组件选型and最佳实践总结(2)----断点续传 1. 断点续传的原理 1 2. 如何判断一个插件/控件是否支持断点续传?? 1 3. 常用的组件选型结果::马 1 4. 自定 ...
- paip.重装系统后firefox火狐收藏夹的恢复
paip.重装系统后firefox火狐收藏夹的恢复 1.使用procmon跟踪ff保存收藏时候的读写文件.. D:\Users\attilax\AppData\Roaming\Mozilla\Fire ...
- shiny server SparkR web展示界面(一)
1. shiny server简介 shiny-server是一种可用把R 语言以web形式展示的服务,下面就讲讲如何在自己的服务器上构建Shiny Server.下一篇主要介绍如何集成sparkR后 ...
- Mac OS X 系统下自带的文本文件格式转换工具iconv
1. utf-8 转 GBK的方法 在mac bash 中直接运行 iconv -f UTF-8 -t GBK test_utf8.txt > test_gbk.txt 举例:创建测试文件 ec ...
- iOS开发-友盟分享(1)
1.集成友盟分享,需要先注册一个友盟账号,注册地址 友盟开发者平台官网 友盟集成文档 友盟sdk下载地址友盟sdk下载地址 2,成功下载sdk集成后,微信分享需要配置一下 新浪微博 之类到同样配置就 ...
- Linux内核启动分析过程-《Linux内核分析》week3作业
环境搭建 环境的搭建参考课件,主要就是编译内核源码和生成镜像 start_kernel 从start_kernel开始,才真正进入了Linux内核的启动过程.我们可以把start_kernel看做平时 ...
- MySQL基础操作(一)
1. 连接数据库mysql -h localhost -u root -p 123456 2. 查看数据库版本select version(); 3. 查看数据库支持的存储引擎和当前默认存储引擎sho ...
- 利用BitLocker和vhdx创建一个有加密的Win10系统
如果电脑不支持TPM加密BitLocker,就无法对系统盘进行全盘加密. 可以采用一个变通的方法:创建一个vhdx,将这个虚拟磁盘进行BitLocker加密,然后在这个盘里安装操作系统,最后把vhdx ...
- 12套swift学习资源分享
虽然objective-c编程语言在过去很长一段时间都是iOS应用开发的基础语言,且很多iOS开发者对其也深爱有佳,但是随着swift编程语言的问世,迅速发展为开发者追捧的语言.且今年伴随着swift ...