这种方法到底哪错了,求助!
查看原帖
这种方法到底哪错了,求助!
135614
许你浮生若梦楼主2018/11/1 23:19
#include<bits/stdc++.h>
using namespace std;
int x1,Y1,x2,y2,n,a[100005],b[100005],ch[100005],dh[100005],d[100005][3],mi1,mi2,an1,an2,ans;
int juli(int q,int w,int e,int r){

    return (q-e)*(q-e)+(w-r)*(w-r);
}
int main(){
    mi1=-1;mi2=-1;an1=-1;an2=-1;
    cin>>x1>>Y1>>x2>>y2;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i]>>b[i];
    for(int i=1;i<=n;i++){
    if(juli(x1,Y1,a[i],b[i])<juli(x2,y2,a[i],b[i])){
    ch[i]=juli(x1,Y1,a[i],b[i]);
    }
    else {
    dh[i]=juli(x2,y2,a[i],b[i]);}

}
for(int i=1;i<=n;i++)
mi1=max(ch[i],mi1);
for(int i=1;i<=n;i++)
mi2=max(dh[i],mi2);

cout<<mi1+mi2<<endl;
return 0;
}
2018/11/1 23:19
加载中...