poj 2926 Requirements N维最远曼哈顿距离

以前写过1~3维的最远曼哈顿距离,(本博客第一篇,代码奇丑)这次写N维,可作模版。

复杂度:O(n*2^m)  (n个点,m维)

原理: |x1-y1|+|x2-y2|+... ...+|xm-ym| 去掉绝对值后x、y分别都有2^m种状态,枚举之。

#include 
#include 
#include 
#include 
#include 
using namespace std;
const int dem=5;        //维数
const int maxxn=100005;
const double inf=1e200;
struct Point{
    double x[dem];
}p[maxxn];
int n;
double minx[1<>=1;
            }
            if(maxx[j]s)minx[j]=s;
        }
    }
    for(i=0; ians)
        ans=maxx[i]-minx[i];
    }
    return ans;
}
int main(){
    //freopen("1.txt", "r", stdin);
    int i, j;
    while(scanf("%d", &n)!=EOF){
        for(i=0; i


 

 

你可能感兴趣的:(计算几何)