#include <iostream>using namespace std;//own coordinates enemy coordinates (A, b) double a[6]={ 0,1,2,3,4,5};d ouble b[6]={0,1,2,3,4,5};d ouble c[6]={999};int who=0;void fun () { for (int i=1;i<6;i++) { a[i]-=a[0];b[i]-=b[0]; } for (int i=1;i<6;i++) { c[i]=a[i]*a[i]+b [I]*b[i]; } for (int i=1;i<6;i++) { if (c[i]<c[0]) {c[0]=c[i];who=i;} } cout<<who<<endl;} n Multiple points of optimization void fun () { for (int i=1;i<6;i++) { //all mappings to the first region a[i]-=a[0];b[i]-=b[0]; if (a[i]<0) a[i]*=-1; if (b[i]<0) b[i]*=-1; } for (int i=1;i<6;i++) { //all mappings to First 1/2 if (A[i]<b[i]) Swap (a[i],b[i]); } for (int i=1;i<6;i++ ) { //Find the smallest x, if (a[i]<=a[1]) whos=i; } for (int i=1;i<6;i++) { //x with Take the if with the largest Y value (a[i]==a[whos]&&b[i]>= B[whos]) Whos=i; } cout<<who<<endl;} Int main () {cout << "hello,c++ world of anycodex!" << endl;fun (); return 0;}
Stay in communication
"Find out the distance in the plane of your nearest enemy" without calculating the distance