poj1046 枚举
来源:互联网 发布:2016淘宝女装店铺推荐 编辑:程序博客网 时间:2024/06/03 19:30
题意:给定16个点作为目标点,然后任给出一点p,根据距离公式,计算距点p最近的目标点。
算法:枚举
#include <iostream>using namespace std;int r,g,b;int target[16][3];int main(){double d, ans;int key;for (int i=0; i<16; i++){cin >> target[i][0] >> target[i][1] >> target[i][2];}while (cin >> r >> g >> b){if (r == -1 && g == -1 && b == -1){break;}ans = 255*255*3+10;for (int i=0; i<16; i++){d = (target[i][0]-r)*(target[i][0]-r) + (target[i][1]-g)*(target[i][1]-g) + (target[i][2]-b)*(target[i][2]-b);if (d < ans){ans = d;key = i;}}cout << "(" << r << "," << g << "," << b << ") maps to (" << target[key][0] << "," << target[key][1] << "," << target[key][2] << ")" << endl;}}
0 0
- poj1046 枚举
- poj1046 枚举法
- POJ1046简单枚举
- POJ1046
- POJ1046
- poj1046
- poj1046
- poj1046
- poj1046
- POJ1046
- poj1046
- poj1046
- poj1046
- POJ1046解题报告
- POJ1046解题报告
- poj1046 简单题
- 1poj1046(水题)
- poj1046 color me less
- 插入文档命令
- 对于日访问量达到1W IP的处理方法
- 【网虫】怎么知道网站是什么线路的?
- 更新文档命令
- const有什么用途?
- poj1046 枚举
- 手把手教你XIB拖商城类应用的待发货列表
- 删除文档命令
- 安卓service 基础
- 查询文档命令
- Kesci“魔镜杯”风控算法大赛复赛解决方案
- Setting
- MySQL压缩表
- 分页.排序.索引命令