Tanky WooRSS

POJ 1046 Color Me Less(水题)

09 Apr 2011
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

题目传送门:http://poj.org/problem?id=1046

毫无技术含量,直接暴力。

#include 
using namespace std;

typedef struct triple{
    int r, g, b;
}Triple;

Triple triples[16], tt;

int fun(Triple m, Triple n)
{
    return (m.r-n.r)*(m.r-n.r) + (m.g-n.g)*(m.g-n.g) + (m.b-n.b)*(m.b-n.b);
}

int main()
{
    //freopen("input.txt", "r", stdin);
    for(int i=0; i<16; ++i)
        cin >> triples[i].r >> triples[i].g >> triples[i].b;
    //int a, b, c;
    while(cin >> tt.r >> tt.g >> tt.b && !(tt.r==-1&&tt.g;==-1&&tt.b;==-1))
    {
        int ans = 999999, cnt=0;
        for(int i=0; i<16; ++i)
            if(fun(triples[i], tt) < ans)
            {
                ans = fun(triples[i], tt);
                cnt = i;
            }
            cout << "(" << tt.r << "," << tt.g << "," << tt.b << ") maps to (" << triples[cnt].r << "," << triples[cnt].g << "," << triples[cnt].b << ")\n" ;
    }
    return 0;
}