摘要: 题目要求两点间的最大值作为距离即:即是切比雪夫距离。而切比雪夫距离与曼哈顿距离的转换却很巧妙。把平面坐标所有点绕原点逆向旋转45度后,所得点的曼哈顿距离之和除以√2,即是切雪比夫距离。旋转点的公式是提取无理数,即每个新坐标可以是(x-y,x+y)。计算其曼哈顿距离后除以2即可。#include #i... 阅读全文
posted @ 2014-10-29 16:22 chenjunjie1994 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 求的是曼哈顿距离。可以把X,Y的距离分开来求。其中,求X、Y的距离可以通过排序后递推的方式求出值的。#include #include #include #include #define LL __int64using namespace std;struct point{ int x,y; int... 阅读全文
posted @ 2014-10-29 15:30 chenjunjie1994 阅读(104) 评论(0) 推荐(0) 编辑