#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
int a,b;
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int x1,x2,y1,y2;
cin>>x1>>y1>>x2>>y2;
int n;
cin>>n;
node num[n];
int ans1=0,ans2=0;
for(int i=0;i<n;i++){
cin>>num[i].a>>num[i].b;
if((num[i].a-x1)*(num[i].a-x1)+(num[i].b-y1)*(num[i].b-y1)-ans1<(num[i].a-x2)*(num[i].a-x2)+(num[i].b-y2)*(num[i].b-y2)-ans2){
ans1=max(ans1,(num[i].a-x1)*(num[i].a-x1)+(num[i].b-y1)*(num[i].b-y1));
}
else{
ans2=max(ans2,(num[i].a-x2)*(num[i].a-x2)+(num[i].b-y2)*(num[i].b-y2));
}
}
cout<<ans1+ans2;
return 0;
}
請問做法哪裡錯了嗎
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct node{
int a,b;
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int x1,x2,y1,y2;
cin>>x1>>y1>>x2>>y2;
int n;
cin>>n;
node num[n];
int ans1=0,ans2=0;
for(int i=0;i<n;i++){
cin>>num[i].a>>num[i].b;
if((num[i].a-x1)*(num[i].a-x1)+(num[i].b-y1)*(num[i].b-y1)-ans1<(num[i].a-x2)*(num[i].a-x2)+(num[i].b-y2)*(num[i].b-y2)-ans2){
ans1=max(ans1,(num[i].a-x1)*(num[i].a-x1)+(num[i].b-y1)*(num[i].b-y1));
}
else{
ans2=max(ans2,(num[i].a-x2)*(num[i].a-x2)+(num[i].b-y2)*(num[i].b-y2));
}
}
cout<<ans1+ans2;
return 0;
}
請問做法哪裡錯了嗎
瓜瓜喜歡孫瑜婕
去問他~